So i'm making a command that outputs every user in a role
module.exports = {
name: 'in-role',
description: 'Find all users in a specified role.',
aliases: ['inrole'],
async execute(message, args, Discord) {
const role = message.guild.roles.cache.get(args[0])
if (role) {
const roleMembers = role.members.map(member => member.toString())
const inRoleEmbed = new Discord.MessageEmbed()
.setTitle(role.name)
.setDescription(roleMembers.join('\n'))
.setColor(role.hexColor);
message.channel.send(inRoleEmbed).catch(error => {
message.channel.send('There was an error executing the command.')
console.log(error)
})
}
}
};
heres the code, it's only caching the top/first 2 members in the guild. Wondering if there is a way to make it get every member and then output all of the users in that role instead of only looking at top 2 members.