GuildMemberRoleManager.remove() removes more than one role
I'm calling GuildMemberRoleManager.remove() in my code, supplying it with an Array containing a single role.
However, this also removes another role I haven't specified.
Things I've already checked:
1. I started logging the array right before calling the method. Array still only contains the single role.
2. Logging also showed that I'm not calling the method (or parent function) twice.
3. The only other method that could remove roles
.set()
does not get called.
4. This doesn't seem to be caused by run time conditions stemming from forgotten await statements.
Relevant code:
Repo: https://github.com/NKN1396/Discord-EmojiToRole/blob/f2500c0254841118c628c342d45780b3e42aa15c/src/trackReactions.mjs#L161
Help would be greatly appreciated, as I've been grinding my teeth out for the past 2 hours.5 Replies
(forgot image for "after")
Do you have the
GuildMembers
intent enabled?No, as I don't want to use privileged intents
Well thats the issue here. The internal role cache for discord.js likely doesn't know that the other role has been added. When you provide an array, it internally calculates the difference and calls
.set
iirc
But its doing that with an invalid cache
So it's setting it to a list that is missing bothI actually just wanted to upload a video of it, but I think your response is already hinting me into the correct direction.
Thank you very much for the insight, I'll try caching the roles before calling
.remove