#hello ๐ question please so i came
1 messages ยท Page 1 of 1 (latest)
module.exports = {
name: 'rolecount', //name of your command
description: 'Count the number of members with roles in this server.', //description of your command
run: async(client, message, args) => {
let embed = new MessageEmbed()
.setTitle(`Role Count`)
.setDescription(`${message.guild.members.cache.filter(m => m.roles.cache.size == 1).size.toLocaleString()}`)
message.channel.send({ embeds: [embed] })
}
}```
this is my code btw
not all members are cached, so you probably would have to use guild.members.fetch()
also you would need the GUILD_MEMBERS intent
@pallid pier its getting a result "unudefined"
im trying to message count of members with no rooles (only the @ everyone role)
partials: ["MESSAGE", "CHANNEL", "REACTION", "GUILD_MEMBER"],
intents: 32767,
});```
this is my added intent
module.exports = {
name: 'rolecount', //name of your command
description: 'Count the number of members with roles in this server.', //description of your command
run: async(client, message, args) => {
let embed = new MessageEmbed()
.setTitle(`Role Count`)
.setDescription(`${message.guild.members.fetch(m => m.roles.cache.size == 1).size}`)
message.channel.send({ embeds: [embed] })
}
}```
and the command's code
const members = await message.guild.members.fetch();
members.filter(...)```
GuildMemberManager#fetch()
Fetches member(s) from Discord, even if they're offline.