disnake
disnake copied to clipboard
refactor: store invokable application commands properly
Summary
Currently, disnake.ext.commands framework doesn't allow registering 2 guild commands with the same type and name in different guilds, even though discord API allows to do that (see issue #260). This PR solves this problem.
Consequences
all_xxx_commandsattributes ofInteractionBotBaseare now deprecated in favor ofall_app_commandsbot.add_xxx_commandmethods are now deprecated in favor ofadd_app_commandbot.remove_xxx_commandmethods are now deprecated in favor ofremove_app_commandbot.get_xxx_commandnow works in O(1) only ifguild_idis specified, otherwise it's O(n) where n = len(all_app_commands)bot.get_xxx_commandcan be ambiguous ifguild_idis not specified- argument
guild_idofbot._ordered_unsynced_commandsis now deprecated
Note
The original idea of allowing to insert IDs of app commands to the corresponding invokable objects had to be abandoned. This is due to complications related to copying.
Checklist
- [x] If code changes were made, then they have been tested
- [x] I have updated the documentation to reflect the changes
- [x] I have formatted the code properly by running
pdm lint - [x] I have type-checked the code by running
pdm pyright
- [x] This PR fixes an issue
- [x] 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, ...)
Haven't tested much yet - not sure what exactly happened, but something somewhere ended up trying to register subcommands as top-level commands: https://gist.github.com/shiftinv/eddfcae9ca1f34790ced4a5288e3691f
Haven't tested much yet - not sure what exactly happened, but something somewhere ended up trying to register subcommands as top-level commands: https://gist.github.com/shiftinv/eddfcae9ca1f34790ced4a5288e3691f
Fixed this in https://github.com/DisnakeDev/disnake/pull/1107/commits/1f10a8df8f67b47d2ebb5257b82a2bd346227421