Any better ways to get ALL guild members that have a specific server role?

Small question for those that know, is there any better way to get all guild members that have a specific guild role that doesn't require me to fetch and cache every single guild member in the server before grabbing them from the djs cache? I ask cause the bot I'm writing is stuck pulling over 10,000+ guild members just trying to figure out what members have specific roles, and it seems very wasteful / abusive if I have to download all this data at once from the API when all I'm trying to get is like, 25 members from the 10,000+ pool.
8 Replies
d.js toolkit
d.js toolkit•10mo 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! - ✅ Marked as resolved by OP
treble/luna
treble/luna•10mo ago
<Role>.members relies on cache so you will have to fetch
Mitzey
Mitzey•10mo ago
is role.members the only way?
treble/luna
treble/luna•10mo ago
additionally you can fetch and pass cache: false, should just return a collection which you can filter through
Mitzey
Mitzey•10mo ago
Fetch on which manager?
treble/luna
treble/luna•10mo ago
GuildMemberManager
Mitzey
Mitzey•10mo ago
I mean, this still seems like I'll have to download all members then filter, so sounds like theres no other way around it for the moment
space
space•10mo ago
There unfortunately is not.
Want results from more Discord servers?
Add your server