Roles Cache sometimes inconsistent

I got very simple code
const role = channel.guild.roles.cache.get(pingRoleId);
size = role?.members?.size
const role = channel.guild.roles.cache.get(pingRoleId);
size = role?.members?.size
And the size is sometimes different, and after restart of the application the cache is correct again and shows the correct size Is there a way to manually refresh the cache or to prevent this issue?
4 Replies
d.js toolkit
d.js toolkit4w 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!
sraech
sraechOP4w ago
current version: v14.16.3 issue existed in v14.13.3 aswell i do have the guildmembers intent do i understand correctly, that i have to fetch guildmembers first, so that i have the full roles
treble/luna
treble/luna4w ago
Roles are always cached. You need to fetch to get all members in a role yes
sraech
sraechOP4w ago
just to clarify since its a bug i cant easily reproduce imo if i fetch and do nothing with the result, the cache gets updated aswell?
Want results from more Discord servers?
Add your server