I’m trying to count members of specific role but i’m getting error, message.guild.fetchMembers() is not a function
let guild = await message.guild.fetchMembers();
let roleID = '3933783737379';
let memberCount = guild.roles.get(roleID).members.size;
message.channel.send(memberCount + " members have this role!");
});
So if i just delete guild variable to make the code the code like this
let roleID = '3933783737379';
let memberCount = message.guild.roles.get(roleID).members.size;
message.channel.send(memberCount + " members have this role!");
He will count him self if he has it and count the owner only no one else counted
Is there any idea how to make this work?
message.guild.fetchMember(); is not a thing in discord.js v12.
Discord.js v12 its
message.guild.members.fetch();
Also members.fetch(); returns a GuildMemberCollection -> GuildMemberManager.fetch()
not a guild object. Just await the fetch function and it should work with your second code! :)