我想看看我的服务器中有多少人具有Helper
角色。
到目前为止,我的代码:
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.\n\Sunucudaki Helper Listesi: ${members}`)
.setFooter(`${message.author.tag}`, message.author.displayAvatarURL())
if (message.content === `${prefix}server`)
message.channel.send(sunucuTanıtım)
})
答案 0 :(得分:1)
Role
具有一个名为members
的属性,即Collection
。因此,您可以使用:
console.log(Role.members.cache.size)
// --> 50 (depending on how many people have the role)