Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: trigger userUpdate on GUILD_MEMBER_UPDATE #4697

Merged
merged 1 commit into from
Aug 14, 2020

Conversation

advaith1
Copy link
Contributor

@advaith1 advaith1 commented Aug 13, 2020

Please describe the changes this PR makes and why it should be merged:

The USER_UPDATE gateway event only triggers when the bot's user itself is updated, but discord.js's userUpdate event triggers when any user known user is updated.

Currently, the userUpdate event triggers on the USER_UPDATE gateway event as well as the PRESENCE_UPDATE event.
However, due to the addition of Intents, Discord now also sends user updates in the GUILD_MEMBER_UPDATE event:

GUILD_MEMBER_UDPATE will now fire when a user changes so that bots that want to opt out of presence can still receive updated user attributes.

(from discord/discord-api-docs#1307 (comment))

This PR updates discord.js to also trigger the userUpdate event on the GUILD_MEMBER_UPDATE events, for users who are using the GUILD_MEMBERS intent but not the GUILD_PRESENCES event. I copied the relevant code from the PresenceUpdate action to the GUILD_MEMBER_UPDATE handler.
It also updates documentation to clarify which events trigger userUpdate.

resolves #4279, related to #4169

Status

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@advaith1
Copy link
Contributor Author

advaith1 commented Aug 14, 2020

looks like discord.js (unmodified) doesnt trigger guildMemberUpdate in the first place without the GUILD_PRESENCES intent, so that should be fixed first

never mind, it was because the member isnt cached without presence intents until they do something like sending a message, this works

@advaith1 advaith1 marked this pull request as draft August 14, 2020 02:44
@advaith1 advaith1 marked this pull request as ready for review August 14, 2020 03:02
@iCrawl iCrawl merged commit 178439e into discordjs:master Aug 14, 2020
@advaith1 advaith1 deleted the userupdate branch August 15, 2020 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch "userUpdate" from Presence Intent to GUILD_MEMBERS Intent
4 participants