Conversation
shiftinv
left a comment
There was a problem hiding this comment.
I have a bunch of mostly minor comments, but overall this looks really cool 👀
|
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 |
Also adds `alias_conflict` attribute for backwards compatibility
Fixed this in 1f10a8d |
…and-storage # Conflicts: # disnake/ext/commands/base_core.py
| # this happens to always be a slash command, the instance check is | ||
| # for `None` and to appease the type-checker | ||
| slash_command = self._all_app_commands.get(cmd_index) | ||
| if not isinstance(slash_command, InvokableSlashCommand): | ||
| return |
There was a problem hiding this comment.
if slash_command is None:
return
assert isinstance(slash_command, InvokableSlashCommand)There was a problem hiding this comment.
As it stands right now this might be better, though silently returning for unexpected types is a little more future-proof, if another autocomplete-able application command type is added at some point in the future
| or :data:`None` if it was a global command. | ||
| """ | ||
|
|
||
| def __init__(self, cmd_type: ApplicationCommandType, name: str, guild_id: int | None) -> None: |
There was a problem hiding this comment.
This exception has pretty much the same signature as AppCmdIndex, perhaps it could accept the index itself?
It's only use site already does ApplicationCommandRegistrationError(cmd_index.type, cmd_index.name, cmd_index.guild_id)
There was a problem hiding this comment.
Fair enough, yea. Updated in 769e254. It still ends up unpacking the AppCmdIndex into its constituent parts inside ApplicationCommandRegistrationError (don't want to expose AppCmdIndex too much, though it is documented nonetheless), but this at least simplifies creating it.
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com> Signed-off-by: vi <8530778+shiftinv@users.noreply.github.com>
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com> Signed-off-by: vi <8530778+shiftinv@users.noreply.github.com>
Summary
Currently,
disnake.ext.commandsframework 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 specifiedguild_idofbot._ordered_unsynced_commandsis now deprecatedNote
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
pdm lintpdm pyright