From 24f8f8d4a7f8ba77c133c76687955011dd90d836 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 31 Mar 2022 23:10:13 -0400 Subject: [PATCH] Rename MaxCommandsReached to CommandLimitReached --- discord/app_commands/errors.py | 4 ++-- discord/app_commands/tree.py | 16 ++++++++-------- docs/interactions/api.rst | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/discord/app_commands/errors.py b/discord/app_commands/errors.py index a053113c6..87dabd83c 100644 --- a/discord/app_commands/errors.py +++ b/discord/app_commands/errors.py @@ -38,7 +38,7 @@ __all__ = ( 'CommandAlreadyRegistered', 'CommandSignatureMismatch', 'CommandNotFound', - 'MaxCommandsReached', + 'CommandLimitReached', 'NoPrivateMessage', 'MissingRole', 'MissingAnyRole', @@ -333,7 +333,7 @@ class CommandNotFound(AppCommandError): super().__init__(f'Application command {name!r} not found') -class MaxCommandsReached(AppCommandError): +class CommandLimitReached(AppCommandError): """An exception raised when the maximum number of application commands was reached either globally or in a guild. diff --git a/discord/app_commands/tree.py b/discord/app_commands/tree.py index 4bafdb6f5..8f7a46f10 100644 --- a/discord/app_commands/tree.py +++ b/discord/app_commands/tree.py @@ -55,7 +55,7 @@ from .errors import ( CommandAlreadyRegistered, CommandNotFound, CommandSignatureMismatch, - MaxCommandsReached, + CommandLimitReached, ) from ..errors import ClientException from ..enums import AppCommandType, InteractionType @@ -195,7 +195,7 @@ class CommandTree(Generic[ClientT]): Raises -------- - MaxCommandsReached + CommandLimitReached The maximum number of commands was reached for that guild. This is currently 100 for slash commands and 5 for context menu commands. """ @@ -207,7 +207,7 @@ class CommandTree(Generic[ClientT]): mapping.update(self._global_commands) if len(mapping) > 100: - raise MaxCommandsReached(guild_id=guild.id, limit=100) + raise CommandLimitReached(guild_id=guild.id, limit=100) ctx_menu: Dict[Tuple[str, Optional[int], int], ContextMenu] = { (name, guild.id, cmd_type): cmd @@ -219,7 +219,7 @@ class CommandTree(Generic[ClientT]): for cmd_type, count in counter.items(): if count > 5: as_enum = AppCommandType(cmd_type) - raise MaxCommandsReached(guild_id=guild.id, limit=5, type=as_enum) + raise CommandLimitReached(guild_id=guild.id, limit=5, type=as_enum) self._context_menus.update(ctx_menu) self._guild_commands[guild.id] = mapping @@ -262,7 +262,7 @@ class CommandTree(Generic[ClientT]): TypeError The application command passed is not a valid application command. Or, ``guild`` and ``guilds`` were both given. - MaxCommandsReached + CommandLimitReached The maximum number of commands was reached globally or for that guild. This is currently 100 for slash commands and 5 for context menu commands. """ @@ -285,7 +285,7 @@ class CommandTree(Generic[ClientT]): total = sum(1 for _, g, t in self._context_menus if g == guild_id and t == type) if total + found > 5: - raise MaxCommandsReached(guild_id=guild_id, limit=5, type=AppCommandType(type)) + raise CommandLimitReached(guild_id=guild_id, limit=5, type=AppCommandType(type)) data[key] = command if guild_ids is None: @@ -316,7 +316,7 @@ class CommandTree(Generic[ClientT]): if found and not override: raise CommandAlreadyRegistered(name, guild_id) if len(commands) + found > 100: - raise MaxCommandsReached(guild_id=guild_id, limit=100) + raise CommandLimitReached(guild_id=guild_id, limit=100) # Actually add the command now that it has been verified to be okay. for guild_id in guild_ids: @@ -327,7 +327,7 @@ class CommandTree(Generic[ClientT]): if found and not override: raise CommandAlreadyRegistered(name, None) if len(self._global_commands) + found > 100: - raise MaxCommandsReached(guild_id=None, limit=100) + raise CommandLimitReached(guild_id=None, limit=100) self._global_commands[name] = root @overload diff --git a/docs/interactions/api.rst b/docs/interactions/api.rst index 1fb74500c..38fe51feb 100644 --- a/docs/interactions/api.rst +++ b/docs/interactions/api.rst @@ -575,7 +575,7 @@ Exceptions .. autoexception:: discord.app_commands.CommandOnCooldown :members: -.. autoexception:: discord.app_commands.MaxCommandsReached +.. autoexception:: discord.app_commands.CommandLimitReached :members: .. autoexception:: discord.app_commands.CommandAlreadyRegistered @@ -603,7 +603,7 @@ Exception Hierarchy - :exc:`~discord.app_commands.MissingPermissions` - :exc:`~discord.app_commands.BotMissingPermissions` - :exc:`~discord.app_commands.CommandOnCooldown` - - :exc:`~discord.app_commands.MaxCommandsReached` + - :exc:`~discord.app_commands.CommandLimitReached` - :exc:`~discord.app_commands.CommandAlreadyRegistered` - :exc:`~discord.app_commands.CommandSignatureMismatch` - :exc:`~discord.app_commands.CommandNotFound`