fix: correctly serialize slash cmd with same names from different scope #1733
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Type
Description
Trying to make two non-sub slash commands with the same name but a different
scopes
results in an error message when trying to sync these slash commands.This is because our
application_commands_to_dict
, if multiple slash commands under the same name were found, only used the scope of the first command in the list for serialization purposes.This later causes issues between the dict generated by this command and
bot.interactions_by_scope
sinceinteractions_by_scope
now has a command in a scope thatapplication_commands_to_dict
did not account for, causing an error when syncing.This PR fixes all of that by making sure all slash commands with the same name are properly serialized. Because I was there already, this PR also refactors
application_commands_to_dict
a tiny bit to be nicer.Changes
cmd_list
(a list representing slash commands with the same name) in the final, serialized result instead of only taking the scope of the first command and ignoring other commands.application_commands_to_dict
since I was here anyways.Related Issues
N/A
Test Scenarios
Python Compatibility
3.10.x
3.11.x
Checklist
pre-commit
code linter over all edited files