Exceptions#
Exception Hierarchy#
Objects#
The following exceptions are thrown by the library.
- exception discord.DiscordException[source]#
Base exception class for pycord
Ideally speaking, this could be caught to handle any exceptions raised from this library.
- exception discord.ClientException[source]#
Exception that’s raised when an operation in the
Client
fails.These are usually for exceptions that happened due to user input.
- exception discord.LoginFailure[source]#
Exception that’s raised when the
Client.login()
function fails to log you in from improper credentials or some other misc. failure.
- exception discord.NoMoreItems[source]#
Exception that is raised when an async iteration operation has no more items.
- exception discord.HTTPException(response, message)[source]#
Exception that’s raised 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.Forbidden(response, message)[source]#
Exception that’s raised for when status code 403 occurs.
Subclass of
HTTPException
- exception discord.NotFound(response, message)[source]#
Exception that’s raised for when status code 404 occurs.
Subclass of
HTTPException
- exception discord.DiscordServerError(response, message)[source]#
Exception that’s raised for when a 500 range status code occurs.
Subclass of
HTTPException
.New in version 1.5.
- exception discord.InvalidData[source]#
Exception that’s raised when the library encounters unknown or invalid data from Discord.
- exception discord.InvalidArgument[source]#
Exception that’s raised when an argument to a function is invalid some way (e.g. wrong value or wrong type).
This could be considered the parallel of
ValueError
andTypeError
except inherited fromClientException
and thusDiscordException
.
- exception discord.GatewayNotFound[source]#
An exception that is raised when the gateway for Discord could not be found
- exception discord.ConnectionClosed(socket, *, shard_id, code=None)[source]#
Exception that’s raised when the gateway connection is closed for reasons that could not be handled internally.
- exception discord.PrivilegedIntentsRequired(shard_id)[source]#
Exception that’s raised 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:
- Parameters:
shard_id (int | None) –
- exception discord.InteractionResponded(interaction)[source]#
Exception that’s raised when sending another interaction response using
InteractionResponse
when one has already been done before.An interaction can only respond once.
New in version 2.0.
- interaction#
The interaction that’s already been responded to.
- Type:
- Parameters:
interaction (
Interaction
) –
- exception discord.opus.OpusError(code)[source]#
An exception that is thrown for libopus related errors.
- Parameters:
code (
int
) –
- exception discord.opus.OpusNotLoaded[source]#
An exception that is thrown for when libopus is not loaded.
- exception discord.ApplicationCommandError[source]#
The base exception type for all application command related errors.
This inherits from
DiscordException
.This exception and exceptions inherited from it are handled in a special way as they are caught and passed into a special event from
Bot
,on_command_error()
.
- exception discord.CheckFailure[source]#
Exception raised when the predicates in
Command.checks
have failed.This inherits from
ApplicationCommandError
- exception discord.ApplicationCommandInvokeError(e)[source]#
Exception raised when the command being invoked raised an exception.
This inherits from
ApplicationCommandError
- original#
The original exception that was raised. You can also get this via the
__cause__
attribute.- Type:
- Parameters:
e (
Exception
) –
- exception discord.ExtensionError(message=None, *args, name)[source]#
Base exception for extension related errors.
This inherits from
DiscordException
.
- exception discord.ExtensionAlreadyLoaded(name)[source]#
An exception raised when an extension has already been loaded.
This inherits from
ExtensionError
- Parameters:
name (
str
) –
- exception discord.ExtensionNotLoaded(name)[source]#
An exception raised when an extension was not loaded.
This inherits from
ExtensionError
- Parameters:
name (
str
) –
- exception discord.NoEntryPointError(name)[source]#
An exception raised when an extension does not have a
setup
entry point function.This inherits from
ExtensionError
- Parameters:
name (
str
) –
- exception discord.ExtensionFailed(name, original)[source]#
An exception raised when an extension failed to load during execution of the module or
setup
entry point.This inherits from
ExtensionError
- original#
The original exception that was raised. You can also get this via the
__cause__
attribute.- Type:
- exception discord.ExtensionNotFound(name)[source]#
An exception raised when an extension is not found.
This inherits from
ExtensionError
Changed in version 1.3: Made the
original
attribute always None.- Parameters:
name (
str
) –
- exception discord.sinks.RecordingException[source]#
Exception that’s thrown when there is an error while trying to record audio from a voice channel.
New in version 2.0.
- exception discord.sinks.WaveSinkError[source]#
Exception thrown when an exception occurs with
WaveSink
New in version 2.0.
- exception discord.sinks.MP3SinkError[source]#
Exception thrown when an exception occurs with
MP3Sink
New in version 2.0.
- exception discord.sinks.MP4SinkError[source]#
Exception thrown when an exception occurs with
MP4Sink
New in version 2.0.
- exception discord.sinks.M4ASinkError[source]#
Exception thrown when an exception occurs with
M4ASink
New in version 2.0.
- exception discord.sinks.MKVSinkError[source]#
Exception thrown when an exception occurs with
MKVSink
New in version 2.0.