From 8ced1143e3a0a256d2bedbe0c75fbcf3d4eaeab2 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 15 Mar 2022 07:22:44 -0400 Subject: [PATCH] Change missing application ID error to be more descriptive --- discord/app_commands/tree.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/discord/app_commands/tree.py b/discord/app_commands/tree.py index 34400178d..2f1baa4ff 100644 --- a/discord/app_commands/tree.py +++ b/discord/app_commands/tree.py @@ -80,6 +80,11 @@ __all__ = ('CommandTree',) ClientT = TypeVar('ClientT', bound='Client') +APP_ID_NOT_FOUND = ( + 'Client does not have an application_id set. Either the function was called before on_ready ' + 'was called or application_id was not passed to the Client constructor.' +) + def _retrieve_guild_ids( command: Any, guild: Optional[Snowflake] = MISSING, guilds: List[Snowflake] = MISSING @@ -164,7 +169,7 @@ class CommandTree(Generic[ClientT]): The application's commands. """ if self.client.application_id is None: - raise ClientException('Client does not have an application ID set') + raise ClientException(APP_ID_NOT_FOUND) if guild is None: commands = await self._http.get_global_commands(self.client.application_id) @@ -853,7 +858,7 @@ class CommandTree(Generic[ClientT]): """ if self.client.application_id is None: - raise ClientException('Client does not have an application ID set') + raise ClientException(APP_ID_NOT_FOUND) commands = self._get_all_commands(guild=guild) payload = [command.to_dict() for command in commands]