Skip to content

Commit

Permalink
chore: rename AppCommandRegistrationError
Browse files Browse the repository at this point in the history
Also adds `alias_conflict` attribute for backwards compatibility
  • Loading branch information
EQUENOS committed Sep 22, 2023
1 parent 4ed930d commit 192d2b9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion changelog/260.feature.2.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
|commands| Add :class:`AppCommandRegistrationError`.
|commands| Add :class:`ApplicationCommandRegistrationError`.
6 changes: 4 additions & 2 deletions disnake/ext/commands/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"ExtensionFailed",
"ExtensionNotFound",
"CommandRegistrationError",
"AppCommandRegistrationError",
"ApplicationCommandRegistrationError",
"FlagError",
"BadFlagArgument",
"MissingFlagArgument",
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions disnake/ext/commands/interaction_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`.
Expand All @@ -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
)

Expand Down
3 changes: 2 additions & 1 deletion docs/ext/commands/api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Exceptions
.. autoexception:: CommandRegistrationError
:members:

.. autoexception:: AppCommandRegistrationError
.. autoexception:: ApplicationCommandRegistrationError
:members:


Expand Down Expand Up @@ -255,6 +255,7 @@ Exception Hierarchy
- :exc:`ExtensionNotFound`
- :exc:`~.ClientException`
- :exc:`CommandRegistrationError`
- :exc:`ApplicationCommandRegistrationError`

Warnings
--------
Expand Down

0 comments on commit 192d2b9

Please sign in to comment.