im having problems to get all users with certain role

let usuarios =interaction.guild.roles.cache.get('1299746941327904779').members.map(user => user.displayName); im getting some of the results but not all of them, i have more users with that role discord.js v14.16
3 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
NyR
NyR2mo ago
Role#members is just a filter on members cache, so you need to fetch all the members prior to accessing it so they are all cached
d.js docs
d.js docs2mo ago
:method: GuildMemberManager#fetch() @14.16.3 Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
Want results from more Discord servers?
Add your server