Distinguishing role change on partial oldMember in guildMemberUpdate #8409
Closed
pranavbadami
started this conversation in
General
Replies: 1 comment 1 reply
-
Seems you know what the issue is. It then follows that you should ensure all guild members in the server are cached by fetching them or utilise a database for which user ids are against role ids. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which package is this bug report for?
discord.js
Issue description
Hi folks!
My bot's use case is that when a role is added to a member, perform an action such as posting a message. Yesterday, we noticed an issue where, after restart, the
guildMemberUpdate
event was not firing. I realized this was because we weren't using partials: #5685After adding in the
GUILD_MEMBER
partial, however, I am struggling to determine new roles that were added to a member. Specifically, whenguildMemberUpdate
is fired with a partialoldMember
value, it doesn't include any role information for that member. Then, when I fetch theoldMember
upon receiving the event, the fetched data contains all roles present onnewMember
. This makes it so that I can't tell which role was just added or removed.This presents an issue whenever my bot restarts and the first event it seems from a given member is a
guildMemberUpdate
due to a role change.Do y'all have any workarounds or suggestions for this? Thanks in advance!
Code sample
Package version
13.8.0
Node.js version
16.13.1
Operating system
MacOS 12.0.1
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
GuildMember
Which gateway intents are you subscribing to?
GuildMembers
I have tested this issue on a development release
No response
Beta Was this translation helpful? Give feedback.
All reactions