Move MissingApplicationID to top-level discord namespace

This commit is contained in:
Rapptz
2024-08-31 08:51:56 -04:00
parent 66d74054dd
commit df4b1c88df
8 changed files with 39 additions and 26 deletions

View File

@ -47,6 +47,12 @@ __all__ = (
'ConnectionClosed',
'PrivilegedIntentsRequired',
'InteractionResponded',
'MissingApplicationID',
)
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.'
)
@ -278,3 +284,22 @@ class InteractionResponded(ClientException):
def __init__(self, interaction: Interaction):
self.interaction: Interaction = interaction
super().__init__('This interaction has already been responded to before')
class MissingApplicationID(ClientException):
"""An exception raised when the client does not have an application ID set.
An application ID is required for syncing application commands and various
other application tasks such as SKUs or application emojis.
This inherits from :exc:`~discord.app_commands.AppCommandError`
and :class:`~discord.ClientException`.
.. versionadded:: 2.0
.. versionchanged:: 2.5
This is now exported to the ``discord`` namespace and now inherits from :class:`~discord.ClientException`.
"""
def __init__(self, message: Optional[str] = None):
super().__init__(message or APP_ID_NOT_FOUND)