Best way to get userIds in a role without hitting API limit Hourly

I have to get all the userIDs that have a role in a guild on an Hourly basis. It only returns the members in cache that have it. In order to get the updated userIDs every hour: - Do I have to fetch all members ever hour? - What if the role has more than 1000 people?
5 Replies
d.js toolkit
d.js toolkit17mo 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!
space
space17mo ago
If you have the guild members intent, you only need to fetch all members once and should be good then since the cache automatically updates. (Fetching all members will just short-circuit then too)
War
WarOP17mo ago
Thank you! Is there a check I can do to see if the members of a guild are fetched and are in the cache and fetch them if not?
space
space17mo ago
Yeah, you can compare Guild#memberCount with the size of your guild member cache.
War
WarOP17mo ago
Thanks!
Want results from more Discord servers?
Add your server