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
d.js toolkit
d.js toolkit9mo 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
TÆMBØ
TÆMBØ9mo ago
I'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
d.js docs
d.js docs9mo ago
:method: RoleManager#fetch() Obtains a role from Discord, or the role cache if they're already available.
shikoshib
shikoshibOP9mo ago
Uncached means seeing roles as they are right now.
Mark
Mark9mo ago
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
shikoshib
shikoshibOP9mo ago
ok seems like I got it thx
Want results from more Discord servers?
Add your server