Exceptions
The following exceptions are thrown by the library.
- exception discord.DiscordException
Bases:
ExceptionBase exception class for discord.py
Ideally speaking, this could be caught to handle any exceptions thrown from this library.
- exception discord.ClientException
Bases:
DiscordExceptionException that’s thrown when an operation in the
Clientfails.These are usually for exceptions that happened due to user input.
- exception discord.LoginFailure
Bases:
ClientExceptionException that’s thrown when the
Client.login()function fails to log you in from improper credentials or some other misc. failure.
- exception discord.NoMoreItems
Bases:
DiscordExceptionException that is thrown when an async iteration operation has no more items.
- exception discord.HTTPException(response, message)
Bases:
DiscordExceptionException that’s thrown when an HTTP request operation fails.
- response
The response of the failed HTTP request. This is an instance of
aiohttp.ClientResponse. In some cases this could also be arequests.Response.- Type:
- exception discord.Unauthorized(response, message)
Bases:
HTTPExceptionException that’s thrown for when status code 401 occurs.
Subclass of
HTTPExceptionAdded in version 2.0.
- exception discord.Forbidden(response, message)
Bases:
HTTPExceptionException that’s thrown for when status code 403 occurs.
Subclass of
HTTPException
- exception discord.NotFound(response, message)
Bases:
HTTPExceptionException that’s thrown for when status code 404 occurs.
Subclass of
HTTPException
- exception discord.DiscordServerError(response, message)
Bases:
HTTPExceptionException that’s thrown for when a 500 range status code occurs.
Subclass of
HTTPException.Added in version 1.5.
- exception discord.InvalidData
Bases:
ClientExceptionException that’s raised when the library encounters unknown or invalid data from Discord.
- exception discord.InvalidArgument
Bases:
ClientExceptionException that’s thrown when an argument to a function is invalid some way (e.g. wrong value or wrong type).
This could be considered the analogous of
ValueErrorandTypeErrorexcept inherited fromClientExceptionand thusDiscordException.
- exception discord.GatewayNotFound
Bases:
DiscordExceptionAn exception that is usually thrown when the gateway hub for the
Clientwebsocket is not found.
- exception discord.ConnectionClosed(socket, *, shard_id, code=None)
Bases:
ClientExceptionException that’s thrown when the gateway connection is closed for reasons that could not be handled internally.
- shard_id
The shard ID that got closed if applicable.
- Type:
Optional[
int]
- exception discord.PrivilegedIntentsRequired(shard_id)
Bases:
ClientExceptionException that’s thrown when the gateway is requesting privileged intents, but they’re not ticked in the developer page yet.
Go to https://discord.com/developers/applications/ and enable the intents that are required. Currently, these are as follows:
- shard_id
The shard ID that got closed if applicable.
- Type:
Optional[
int]
- exception discord.AlreadyResponded(interaction_id)
Bases:
DiscordExceptionException thrown when attempting to send the callback for an interaction that has already been responded to.’
- exception discord.opus.OpusError(code)
Bases:
DiscordExceptionAn exception that is thrown for libopus related errors.
- exception discord.opus.OpusNotLoaded
Bases:
DiscordExceptionAn exception that is thrown for when libopus is not loaded.
- exception discord.DiscordWarning
Bases:
WarningBase warning class for discord.py
Ideally speaking, this could be caught to handle any warnings thrown from this library.
- exception discord.UnknownInteraction(interaction_id)
Bases:
DiscordWarningA warning that comes when you try to interact with an expired interaction.