本文介绍了如何查看有多少人在特定的不和谐服务器中担任角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我想看看我的服务器中有多少人拥有 Helper
角色.
I want to see how many people in my server have the Helper
role.
到目前为止我的代码:
client.on('message', message =>{
let server = "746326753466908742"
var yourRole = message.guild.roles.cache.find(role => role.name == "Helper");
var members = message.guild.members.cache.filter(member => member.roles.cache.find(role => role == yourRole)).map(member => member.user.tag);
let sunucuTantm = new Discord.MessageEmbed()
.setTitle('IECode Sunucu:')
.setDescription(`Helperlar Aadaki Listeden Grebilirsiniz.
Sunucudaki Helper Listesi: ${members}`)
.setFooter(`${message.author.tag}`, message.author.displayAvatarURL())
if (message.content === `${prefix}server`)
message.channel.send(sunucuTantm)
})
推荐答案
一个Role
有一个名为members
的属性,它是一个Collection
.因此,您可以使用:
A Role
has a property called members
, which is a Collection
. Therefore, you can use:
console.log(Role.members.cache.size)
// --> 50 (depending on how many people have the role)
这篇关于如何查看有多少人在特定的不和谐服务器中担任角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!