diff --git a/changelog/260.feature.2.rst b/changelog/260.feature.2.rst index fb1c42fdee..7abeb8d277 100644 --- a/changelog/260.feature.2.rst +++ b/changelog/260.feature.2.rst @@ -1 +1 @@ -|commands| Add :class:`AppCommandRegistrationError`. +|commands| Add :class:`ApplicationCommandRegistrationError`. diff --git a/disnake/ext/commands/errors.py b/disnake/ext/commands/errors.py index e7ecd8cf28..515951ffda 100644 --- a/disnake/ext/commands/errors.py +++ b/disnake/ext/commands/errors.py @@ -75,7 +75,7 @@ "ExtensionFailed", "ExtensionNotFound", "CommandRegistrationError", - "AppCommandRegistrationError", + "ApplicationCommandRegistrationError", "FlagError", "BadFlagArgument", "MissingFlagArgument", @@ -1026,7 +1026,7 @@ def __init__(self, name: str, *, alias_conflict: bool = False) -> None: # we inherit CommandRegistrationError for backwards compatibility, # because this error replaced CommandRegistrationError in several places -class AppCommandRegistrationError(CommandRegistrationError): +class ApplicationCommandRegistrationError(CommandRegistrationError): """An exception raised when the app command can't be added because a command with the same key already exists. A key is determined by command type, name, and guild_id. @@ -1052,6 +1052,8 @@ def __init__( self.cmd_type: ApplicationCommandType = cmd_type self.name: str = name self.guild_id: Optional[int] = guild_id + # backwards compatibility + self.alias_conflict: bool = False # fixed API naming here because no one calls slash commands "chat input" type_ = "slash" if cmd_type is ApplicationCommandType.chat_input else cmd_type.name if guild_id is None: diff --git a/disnake/ext/commands/interaction_bot_base.py b/disnake/ext/commands/interaction_bot_base.py index 576f047674..4c69f06335 100644 --- a/disnake/ext/commands/interaction_bot_base.py +++ b/disnake/ext/commands/interaction_bot_base.py @@ -40,7 +40,7 @@ message_command, user_command, ) -from .errors import AppCommandRegistrationError +from .errors import ApplicationCommandRegistrationError from .flags import CommandSyncFlags from .slash_core import InvokableSlashCommand, SubCommand, SubCommandGroup, slash_command @@ -347,7 +347,7 @@ def add_app_command(self, app_command: InvokableApplicationCommand) -> None: Raises ------ - AppCommandRegistrationError + ApplicationCommandRegistrationError The app command is already registered. TypeError The app command passed is not an instance of :class:`InvokableApplicationCommand`. @@ -371,7 +371,7 @@ def add_app_command(self, app_command: InvokableApplicationCommand) -> None: type=app_command.body.type, name=app_command.name, guild_id=guild_id ) if cmd_index in self.all_app_commands: - raise AppCommandRegistrationError( + raise ApplicationCommandRegistrationError( cmd_index.type, cmd_index.name, cmd_index.guild_id ) diff --git a/docs/ext/commands/api/exceptions.rst b/docs/ext/commands/api/exceptions.rst index 4dd874f51e..094ac5dbbc 100644 --- a/docs/ext/commands/api/exceptions.rst +++ b/docs/ext/commands/api/exceptions.rst @@ -186,7 +186,7 @@ Exceptions .. autoexception:: CommandRegistrationError :members: -.. autoexception:: AppCommandRegistrationError +.. autoexception:: ApplicationCommandRegistrationError :members: @@ -255,6 +255,7 @@ Exception Hierarchy - :exc:`ExtensionNotFound` - :exc:`~.ClientException` - :exc:`CommandRegistrationError` + - :exc:`ApplicationCommandRegistrationError` Warnings --------