Exceptions¶
Exception Hierarchy¶
Objects¶
The following exceptions are thrown by the library.
- exception discord.DiscordException[исходный код]¶
Base exception class for pycord
Ideally speaking, this could be caught to handle any exceptions raised from this library.
- exception discord.ClientException[исходный код]¶
Exception that’s raised when an operation in the
Clientfails.These are usually for exceptions that happened due to user input.
- exception discord.LoginFailure[исходный код]¶
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[исходный код]¶
Exception that is raised when an async iteration operation has no more items.
- exception discord.HTTPException(response, message)[исходный код]¶
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)[исходный код]¶
Exception that’s raised for when status code 403 occurs.
Subclass of
HTTPException
- exception discord.NotFound(response, message)[исходный код]¶
Exception that’s raised for when status code 404 occurs.
Subclass of
HTTPException
- exception discord.DiscordServerError(response, message)[исходный код]¶
Exception that’s raised for when a 500 range status code occurs.
Subclass of
HTTPException.Добавлено в версии 1.5.
- exception discord.InvalidData[исходный код]¶
Exception that’s raised when the library encounters unknown or invalid data from Discord.
- exception discord.InvalidArgument[исходный код]¶
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[исходный код]¶
An exception that is raised when the gateway for Discord could not be found
- exception discord.ConnectionClosed(socket, *, shard_id, code=None)[исходный код]¶
Exception that’s raised when the gateway connection is closed for reasons that could not be handled internally.
- Параметры:
socket (
ClientWebSocketResponse)
- exception discord.PrivilegedIntentsRequired(shard_id)[исходный код]¶
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)[исходный код]¶
Exception that’s raised when sending another interaction response using
InteractionResponsewhen one has already been done before.An interaction can only respond once.
Добавлено в версии 2.0.
- interaction¶
The interaction that’s already been responded to.
- Type:
- Параметры:
interaction (
Interaction)
- exception discord.opus.OpusError(code=0, message=None)[исходный код]¶
An exception that is thrown for libopus related errors.
- exception discord.opus.OpusNotLoaded[исходный код]¶
An exception that is thrown for when libopus is not loaded.
- exception discord.ApplicationCommandError[исходный код]¶
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[исходный код]¶
Exception raised when the predicates in
Command.checkshave failed.This inherits from
ApplicationCommandError
- exception discord.ApplicationCommandInvokeError(e)[исходный код]¶
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:
- Параметры:
e (
Exception)
- exception discord.ExtensionError(message=None, *args, name)[исходный код]¶
Base exception for extension related errors.
This inherits from
DiscordException.
- exception discord.ExtensionAlreadyLoaded(name)[исходный код]¶
An exception raised when an extension has already been loaded.
This inherits from
ExtensionError- Параметры:
name (
str)
- exception discord.ExtensionNotLoaded(name)[исходный код]¶
An exception raised when an extension was not loaded.
This inherits from
ExtensionError- Параметры:
name (
str)
- exception discord.NoEntryPointError(name)[исходный код]¶
An exception raised when an extension does not have a
setupentry point function.This inherits from
ExtensionError- Параметры:
name (
str)
- exception discord.ExtensionFailed(name, original)[исходный код]¶
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)[исходный код]¶
An exception raised when an extension is not found.
This inherits from
ExtensionErrorИзменено в версии 1.3: Made the
originalattribute always None.- Параметры:
name (
str)
- exception discord.sinks.SinkException[исходный код]¶
Raised when a Sink error occurs.
Добавлено в версии 2.0.
- exception discord.sinks.RecordingException[исходный код]¶
Exception that’s thrown when there is an error while trying to record audio from a voice channel.
Добавлено в версии 2.0.
- exception discord.sinks.WaveSinkError[исходный код]¶
Exception thrown when an exception occurs with
WaveSinkДобавлено в версии 2.0.
- exception discord.sinks.MP3SinkError[исходный код]¶
Exception thrown when an exception occurs with
MP3SinkДобавлено в версии 2.0.
- exception discord.sinks.MP4SinkError[исходный код]¶
Exception thrown when an exception occurs with
MP4SinkДобавлено в версии 2.0.
- exception discord.sinks.M4ASinkError[исходный код]¶
Exception thrown when an exception occurs with
M4ASinkДобавлено в версии 2.0.
- exception discord.sinks.MKVSinkError[исходный код]¶
Exception thrown when an exception occurs with
MKVSinkДобавлено в версии 2.0.
- exception discord.sinks.MKASinkError[исходный код]¶
Exception thrown when an exception occurs with
MKASinkДобавлено в версии 2.0.
- exception discord.sinks.OGGSinkError[исходный код]¶
Exception thrown when an exception occurs with
OGGSinkДобавлено в версии 2.0.
- exception discord.MissingVoiceDependenciesError(missing)[исходный код]¶
Raised when required voice dependencies are not installed.
Примечание
This exception inherits from both
RuntimeErrorandDiscordException.- missing¶
tuple[str, …] The missing dependencies that are required for voice support.