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

Global commands will be sent to Discord to register only if it differs from the existing global commands from Discord's servers #634

Merged
merged 7 commits into from
Dec 26, 2021

Conversation

PenguinDevs
Copy link
Contributor

@PenguinDevs PenguinDevs commented Dec 24, 2021

Summary

The method .register_commands() in the bot.py file of the current version of Pycord always deploy the global slash commands every time the bot is started. This method is not ideal because it is telling Discord to roll out the commands every single time the bot is started when the global slash commands may not differ from the previous deployment of the commands. This method leads therefore leads to the Invalid interaction application command that will occur every single start of the bot for up to one hour. During this period when all global slash commands in the bot will always return Invalid interaction application command rendering it to be unusable by the user.

This pull aims to fix the Invalid interaction application command by using the .register_commands() method to only deploy the global slash commands using the http.bulk_upsert_global_commands() method only if the global commands stored in Discord from http.get_global_commands() has certain attributes that differs from the global commands (no guild_ids) in .pending_application_commands. This means that if the global commands are not changed in the bot's code by comparing to the last deployment of global commands to Discord, users will not receive the Invalid interaction application command. Invalid interaction application command will only occur if the global commands have changed when the bot is started and Discord is still attempting to roll out the global commands taking up to an hour using the new deployment of global commands.

Checklist

  • If code changes were made then they have been tested (only for global slash commands).
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

VincentRPS
VincentRPS previously approved these changes Dec 24, 2021
@Lulalaby
Copy link
Member

Good job
anime-approve

@Dorukyum Dorukyum requested a review from BobDotCom December 24, 2021 13:10
Copy link
Member

@BobDotCom BobDotCom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the suggestions I made on this. In addition, I will work on further improving command registration soon. Partially completes #433.

discord/bot.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
@BobDotCom BobDotCom added good first issue Good for newcomers priority: medium Medium Priority status: in progress Work in Progess labels Dec 24, 2021
@BobDotCom BobDotCom added this to the v2.0 milestone Dec 24, 2021
@BobDotCom BobDotCom enabled auto-merge December 26, 2021 19:46
@Lulalaby Lulalaby disabled auto-merge December 26, 2021 19:49
@Lulalaby Lulalaby merged commit b18324e into Pycord-Development:master Dec 26, 2021
@PenguinDevs PenguinDevs deleted the global-slash-commands branch December 27, 2021 02:50
VincentRPS pushed a commit to VincentRPS/pycord that referenced this pull request Jan 22, 2022
print() -> none
unnecessary if len() > 0 because loop will run anyways
Pycord-Development#634 (review)

Co-Authored-By: BobDotCom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers priority: medium Medium Priority status: in progress Work in Progess
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants