disnake icon indicating copy to clipboard operation
disnake copied to clipboard

refactor: store invokable application commands properly

Open EQUENOS opened this issue 2 years ago • 2 comments

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_commands attributes of InteractionBotBase are now deprecated in favor of all_app_commands
  • bot.add_xxx_command methods are now deprecated in favor of add_app_command
  • bot.remove_xxx_command methods are now deprecated in favor of remove_app_command
  • bot.get_xxx_command now works in O(1) only if guild_id is specified, otherwise it's O(n) where n = len(all_app_commands)
  • bot.get_xxx_command can be ambiguous if guild_id is not specified
  • argument guild_id of bot._ordered_unsynced_commands is 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, ...)

EQUENOS avatar Sep 18 '23 12:09 EQUENOS

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

shiftinv avatar Sep 22 '23 14:09 shiftinv

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

EQUENOS avatar Sep 23 '23 22:09 EQUENOS