我想看看我的服务器中有多少人拥有 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 sunucuTanıtım = new Discord.MessageEmbed()
.setTitle('IECode Sunucu:')
.setDescription(`Helperları Aşşağıdaki Listeden Görebilirsiniz.
Sunucudaki Helper Listesi: ${members}`)
.setFooter(`${message.author.tag}`, message.author.displayAvatarURL())
if (message.content === `${prefix}server`)
message.channel.send(sunucuTanıtım)
})
一个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)
这篇关于如何查看有多少人在特定的不和谐服务器中担任角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!