Exceptions¶
Exception Hierarchy¶
Objects¶
The following exceptions are thrown by the library.
- exception discord.DiscordException[código-fonte]¶
Base exception class for pycord
Ideally speaking, this could be caught to handle any exceptions raised from this library.
- exception discord.ClientException[código-fonte]¶
Exception that’s raised when an operation in the
Clientfails.These are usually for exceptions that happened due to user input.
- exception discord.LoginFailure[código-fonte]¶
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[código-fonte]¶
Exception that is raised when an async iteration operation has no more items.
- exception discord.HTTPException(response, message)[código-fonte]¶
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)[código-fonte]¶
Exception that’s raised for when status code 403 occurs.
Subclass of
HTTPException
- exception discord.NotFound(response, message)[código-fonte]¶
Exception that’s raised for when status code 404 occurs.
Subclass of
HTTPException
- exception discord.DiscordServerError(response, message)[código-fonte]¶
Exception that’s raised for when a 500 range status code occurs.
Subclass of
HTTPException.Adicionado na versão 1.5.
- exception discord.InvalidData[código-fonte]¶
Exception that’s raised when the library encounters unknown or invalid data from Discord.
- exception discord.InvalidArgument[código-fonte]¶
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
ValueErrorandTypeErrorexcept inherited fromClientExceptionand thusDiscordException.
- exception discord.GatewayNotFound[código-fonte]¶
An exception that is raised when the gateway for Discord could not be found
- exception discord.ConnectionClosed(socket, *, shard_id, code=None)[código-fonte]¶
Exception that’s raised when the gateway connection is closed for reasons that could not be handled internally.
- Parâmetros:
socket (
ClientWebSocketResponse)
- exception discord.PrivilegedIntentsRequired(shard_id)[código-fonte]¶
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:
- exception discord.InteractionResponded(interaction)[código-fonte]¶
Exception that’s raised when sending another interaction response using
InteractionResponsewhen one has already been done before.An interaction can only respond once.
Adicionado na versão 2.0.
- interaction¶
The interaction that’s already been responded to.
- Type:
- Parâmetros:
interaction (
Interaction)
- exception discord.opus.OpusError(code=0, message=None)[código-fonte]¶
An exception that is thrown for libopus related errors.
- exception discord.opus.OpusNotLoaded[código-fonte]¶
An exception that is thrown for when libopus is not loaded.
- exception discord.ApplicationCommandError[código-fonte]¶
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[código-fonte]¶
Exception raised when the predicates in
Command.checkshave failed.This inherits from
ApplicationCommandError
- exception discord.ApplicationCommandInvokeError(e)[código-fonte]¶
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:
- Parâmetros:
e (
Exception)
- exception discord.ExtensionError(message=None, *args, name)[código-fonte]¶
Base exception for extension related errors.
This inherits from
DiscordException.
- exception discord.ExtensionAlreadyLoaded(name)[código-fonte]¶
An exception raised when an extension has already been loaded.
This inherits from
ExtensionError- Parâmetros:
name (
str)
- exception discord.ExtensionNotLoaded(name)[código-fonte]¶
An exception raised when an extension was not loaded.
This inherits from
ExtensionError- Parâmetros:
name (
str)
- exception discord.NoEntryPointError(name)[código-fonte]¶
An exception raised when an extension does not have a
setupentry point function.This inherits from
ExtensionError- Parâmetros:
name (
str)
- exception discord.ExtensionFailed(name, original)[código-fonte]¶
An exception raised when an extension failed to load during execution of the module or
setupentry 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)[código-fonte]¶
An exception raised when an extension is not found.
This inherits from
ExtensionErrorAlterado na versão 1.3: Made the
originalattribute always None.- Parâmetros:
name (
str)
- exception discord.sinks.SinkException[código-fonte]¶
Raised when a Sink error occurs.
Adicionado na versão 2.0.
- exception discord.sinks.RecordingException[código-fonte]¶
Exception that’s thrown when there is an error while trying to record audio from a voice channel.
Adicionado na versão 2.0.
- exception discord.sinks.WaveSinkError[código-fonte]¶
Exception thrown when an exception occurs with
WaveSinkAdicionado na versão 2.0.
- exception discord.sinks.MP3SinkError[código-fonte]¶
Exception thrown when an exception occurs with
MP3SinkAdicionado na versão 2.0.
- exception discord.sinks.MP4SinkError[código-fonte]¶
Exception thrown when an exception occurs with
MP4SinkAdicionado na versão 2.0.
- exception discord.sinks.M4ASinkError[código-fonte]¶
Exception thrown when an exception occurs with
M4ASinkAdicionado na versão 2.0.
- exception discord.sinks.MKVSinkError[código-fonte]¶
Exception thrown when an exception occurs with
MKVSinkAdicionado na versão 2.0.
- exception discord.sinks.MKASinkError[código-fonte]¶
Exception thrown when an exception occurs with
MKASinkAdicionado na versão 2.0.
- exception discord.sinks.OGGSinkError[código-fonte]¶
Exception thrown when an exception occurs with
OGGSinkAdicionado na versão 2.0.
- exception discord.MissingVoiceDependenciesError(missing)[código-fonte]¶
Raised when required voice dependencies are not installed.
Nota
This exception inherits from both
RuntimeErrorandDiscordException.- missing¶
tuple[str, …] The missing dependencies that are required for voice support.