User object roles

If a user uses a slash command, is there a guarantee the member object I receive in the handler would be the latest update of that member? I had assumed that would be the case but I'm having behaviour that would suggest the member object I receive does not have the latest up to date information on what roles the user has.
Solution:
Turned out to be user error lol
Jump to solution
6 Replies
Kevin
Kevin10mo ago
member.fetch(true) will re-fetch the member from the discord api and bypass the cache
kyra
kyra10mo ago
Yes, Discord sends up-to-date data, and Discord.js handles it using users._add and members._add, which cache by default.
Ravelt
RaveltOP10mo ago
And would this happen before a precondition is processed by sapphire? Specifically the problem I'm having is that I have a precondition that checks if a role id is in the roles.cache of the member object passed in the precondition handler. People are reporting that it's been randomly working and randomly not working which leads me to believe that something is not up to date
kyra
kyra10mo ago
Before the event is even emitted on Discord.js's side, way before Sapphire can even handle it.
Ravelt
RaveltOP10mo ago
I see I will have to do some deeper investigating Thanks for answering btw
Solution
Ravelt
Ravelt10mo ago
Turned out to be user error lol
Want results from more Discord servers?
Add your server