Prevent caching
Hey there!
Yesterday I had a problem where my bot didn't show the roles it can give in the dashboard, even after moving the bot role to the very top. I had to literally restart the bot to fix it.
Turns out, the roles were cached. Makes sense, because I used
guild.roles.cache.forEach()
to get them.
But that got me thinking: how can I get an uncached roles list in d.js v13?6 Replies
- 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 OPI'm a little unsure what an "uncached roles list" is. You can use
<Guild>.roles.fetch()
to get a Collection of all roles in a given server, however usually all roles are cached if you have the GUILDS intent:method: RoleManager#fetch()
Obtains a role from Discord, or the role cache if they're already available.
Uncached means seeing roles as they are right now.
The roles should be cached by default when the client logs in and is ready
If you have the guilds intent
Unless you sweep them or otherwise modify the cache
ok seems like I got it
thx