Exception Hierarchy
All Pycord exceptions inherit fromDiscordException, which itself inherits from Python’s built-in Exception class.
Base Exceptions
DiscordException
DiscordException
Base exception class for Pycord.Ideally speaking, this could be caught to handle any exceptions raised from this library.
ClientException
ClientException
Exception that’s raised when an operation in the Client fails.These are usually for exceptions that happened due to user input.Inherits from:
DiscordExceptionHTTP Exceptions
HTTPException
HTTPException
Exception that’s raised when an HTTP request operation fails.Attributes:
response(aiohttp.ClientResponse) - The response of the failed HTTP requesttext(str) - The text of the error. Could be an empty stringstatus(int) - The status code of the HTTP requestcode(int) - The Discord specific error code for the failure
DiscordExceptionForbidden
Forbidden
Exception that’s raised for when status code 403 occurs.Subclass of:
HTTPExceptionThis typically means the bot lacks permissions to perform the action.NotFound
NotFound
Exception that’s raised for when status code 404 occurs.Subclass of:
HTTPExceptionThis means the resource you’re trying to access doesn’t exist.DiscordServerError
DiscordServerError
Exception that’s raised for when a 500 range status code occurs.Subclass of:
HTTPExceptionThis indicates an error on Discord’s end.Client Exceptions
InvalidData
InvalidData
Exception that’s raised when the library encounters unknown or invalid data from Discord.Inherits from:
ClientExceptionInvalidArgument
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
ValueError and TypeError except inherited from ClientException and thus DiscordException.Inherits from: ClientExceptionLoginFailure
LoginFailure
Exception that’s raised when the
Client.login() function fails to log you in from improper credentials or some other misc. failure.Inherits from: ClientExceptionConnectionClosed
ConnectionClosed
Exception that’s raised when the gateway connection is closed for reasons that could not be handled internally.Attributes:
code(int) - The close code of the websocketreason(str) - The reason provided for the closureshard_id(Optional[int]) - The shard ID that got closed if applicable
ClientExceptionPrivilegedIntentsRequired
PrivilegedIntentsRequired
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:
Intents.membersIntents.presencesIntents.message_content
shard_id(Optional[int]) - The shard ID that got closed if applicable
ClientExceptionInteractionResponded
InteractionResponded
Exception that’s raised when sending another interaction response using
InteractionResponse when one has already been done before.An interaction can only respond once.Attributes:interaction(Interaction) - The interaction that’s already been responded to
ClientExceptionNoMoreItems
NoMoreItems
Exception that is raised when an async iteration operation has no more items.Inherits from:
DiscordExceptionGatewayNotFound
GatewayNotFound
An exception that is raised when the gateway for Discord could not be found.Inherits from:
DiscordExceptionValidationError
ValidationError
An Exception that is raised when there is a Validation Error.Inherits from:
DiscordExceptionExtension Exceptions
ExtensionError
ExtensionError
Base exception for extension related errors.Attributes:
name(str) - The extension that had an error
DiscordExceptionExtensionAlreadyLoaded
ExtensionAlreadyLoaded
An exception raised when an extension has already been loaded.Inherits from:
ExtensionErrorExtensionNotLoaded
ExtensionNotLoaded
An exception raised when an extension was not loaded.Inherits from:
ExtensionErrorNoEntryPointError
NoEntryPointError
An exception raised when an extension does not have a
setup entry point function.Inherits from: ExtensionErrorExtensionFailed
ExtensionFailed
An exception raised when an extension failed to load during execution of the module or
setup entry point.Attributes:name(str) - The extension that had the errororiginal(Exception) - The original exception that was raised. You can also get this via the__cause__attribute
ExtensionErrorExtensionNotFound
ExtensionNotFound
An exception raised when an extension is not found.Attributes:
name(str) - The extension that had the error
ExtensionErrorApplication Command Exceptions
ApplicationCommandError
ApplicationCommandError
The base exception type for all application command related errors.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.Inherits from: DiscordExceptionCheckFailure
CheckFailure
Exception raised when the predicates in
Command.checks have failed.Inherits from: ApplicationCommandErrorApplicationCommandInvokeError
ApplicationCommandInvokeError
Exception raised when the command being invoked raised an exception.Attributes:
original(Exception) - The original exception that was raised. You can also get this via the__cause__attribute
ApplicationCommandError