Question regarding GuildMemberAdd and GuildMemberUpdate

So my bot currently detects people who donate when they obtain the Premium role in my Discord server. However, I've came to notice (for a while now) that when they join and already have the role appended to them, it doesn't fire GuildMemberUpdate (or at least my bot doesn't detect it). People pledge to us on Patreon and then it gives them the role on Discord, but if they're not in the server, it usually lets them join and also instantly gives them the role. My question is; is this event not fired because it would only fire GuildMemberAdd instead of GuildMemberUpdate? If so, would I then use GuildMemberAdd to obtain the roles they joined with since GuildMemberUpdate isn't being fired?
2 Replies
d.js toolkit
d.js toolkit11mo 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!
AJ
AJ11mo ago
Please ping me when you respond, thanks GPT might have given me the answer here actually Your bot currently detects people who donate and obtain the Premium role in your Discord server. This detection is likely done through some event listener or function in your bot's code. You've noticed that when someone joins the server and already has the Premium role assigned to them (probably through a Patreon integration), your bot doesn't detect any event related to this role assignment. Specifically, it doesn't seem to trigger the GuildMemberUpdate event. The reason behind this behavior is that the GuildMemberUpdate event is only triggered when a member's information (such as roles) is changed after they have already been part of the server. When a new member joins and already has the Premium role, it doesn't trigger this event since the member's information is not being "updated" in this case. Instead, when a new member joins and is instantly given the Premium role, the event that is triggered is likely GuildMemberAdd, which occurs when a new member joins the server. To handle the scenario where a new member joins with the Premium role, you should use the GuildMemberAdd event to obtain the roles they joined with. In the event's data, you can check for the roles assigned to the new member and handle them accordingly. In summary, you can modify your bot's code to use the GuildMemberAdd event to check the roles of new members and take appropriate actions when they join with the Premium role already assigned. This way, you can ensure that your bot properly handles role assignments for new members, even if they already have the Premium role at the time of joining.