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

refactor: only cache commands from own user #6161

Merged
merged 4 commits into from
Jul 23, 2021
Merged

refactor: only cache commands from own user #6161

merged 4 commits into from
Jul 23, 2021

Conversation

ThaTiemsz
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:
The applicationCommandCreate/Update/Delete events are sent when guild commands owned by any bot in the server are created, updated, or deleted - and not just the commands owned by the client user. This meant that Discord.js was caching commands owned by other bots.

This PR:

  • makes sure the command events only cache commands from the own bot (thanks @vladfrangu for the code suggestions)
  • adds ApplicationCommand#applicationId
  • modifies some of the ApplicationCommandManager methods so that they don't patch the cache in place (this fixes a bug where the applicationCommandUpdate event would emit the oldCommand with the new data), unless the targeted command is a global command. (The command events aren't fired for global commands, only guild commands)

Status and versioning classification:

Please move lines that apply to you out of the comment:

  • 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
  • This PR changes the library's interface (methods or parameters added)

@iCrawl iCrawl added this to the Version 13 milestone Jul 21, 2021
@iCrawl iCrawl merged commit 4886ae2 into discordjs:master Jul 23, 2021
@ThaTiemsz ThaTiemsz deleted the master branch August 6, 2021 18:49
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.

None yet

6 participants