Exceptions and Warnings

This section documents exceptions and warnings thrown by the library and their hierarchy.

Exceptions

DiscordException

exception disnake.DiscordException[source]

Base exception class for disnake.

Ideally speaking, this could be caught to handle any exceptions raised from this library.

ClientException

exception disnake.ClientException[source]

Exception that’s raised when an operation in the Client fails.

These are usually for exceptions that happened due to user input.

LoginFailure

exception disnake.LoginFailure[source]

Exception that’s raised when the Client.login() function fails to log you in from improper credentials or some other misc. failure.

NoMoreItems

exception disnake.NoMoreItems[source]

Exception that is raised when an async iteration operation has no more items.

HTTPException

exception disnake.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 a requests.Response.

Type:

aiohttp.ClientResponse

text

The text of the error. Could be an empty string.

Type:

str

status

The status code of the HTTP request.

Type:

int

code

The Discord specific error code for the failure.

Type:

int

Forbidden

exception disnake.Forbidden(response, message)[source]

Exception that’s raised for when status code 403 occurs.

Subclass of HTTPException.

NotFound

exception disnake.NotFound(response, message)[source]

Exception that’s raised for when status code 404 occurs.

Subclass of HTTPException.

DiscordServerError

exception disnake.DiscordServerError(response, message)[source]

Exception that’s raised for when a 500 range status code occurs.

Subclass of HTTPException.

New in version 1.5.

InvalidData

exception disnake.InvalidData[source]

Exception that’s raised when the library encounters unknown or invalid data from Discord.

WebhookTokenMissing

exception disnake.WebhookTokenMissing[source]

Exception that’s raised when a Webhook or SyncWebhook is missing a token to make requests with.

New in version 2.6.

GatewayNotFound

exception disnake.GatewayNotFound[source]

An exception that is raised when the gateway for Discord could not be found

ConnectionClosed

exception disnake.ConnectionClosed(socket, *, shard_id, code=None, voice=False)[source]

Exception that’s raised when the gateway connection is closed for reasons that could not be handled internally.

code

The close code of the websocket.

Type:

int

reason

The reason provided for the closure.

Type:

str

shard_id

The shard ID that got closed if applicable.

Type:

Optional[int]

PrivilegedIntentsRequired

exception disnake.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:

shard_id

The shard ID that got closed if applicable.

Type:

Optional[int]

SessionStartLimitReached

exception disnake.SessionStartLimitReached(session_start_limit, requested=1)[source]

Exception that’s raised when Client.connect() function fails to connect to Discord due to the session start limit being reached.

New in version 2.6.

session_start_limit

The current state of the session start limit.

Type:

SessionStartLimit

InteractionException

exception disnake.InteractionException[source]

Exception that’s raised when an interaction operation fails

New in version 2.0.

interaction

The interaction that was responded to.

Type:

Interaction

InteractionResponded

exception disnake.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 be responded to once.

New in version 2.0.

interaction

The interaction that’s already been responded to.

Type:

Interaction

InteractionNotResponded

exception disnake.InteractionNotResponded(interaction)[source]

Exception that’s raised when editing an interaction response without sending a response message first.

An interaction must be responded to exactly once.

New in version 2.0.

interaction

The interaction that hasn’t been responded to.

Type:

Interaction

InteractionTimedOut

exception disnake.InteractionTimedOut(interaction)[source]

Exception that’s raised when an interaction takes more than 3 seconds to respond but is not deferred.

New in version 2.0.

interaction

The interaction that was responded to.

Type:

Interaction

ModalChainNotSupported

exception disnake.ModalChainNotSupported(interaction)[source]

Exception that’s raised when responding to a modal with another modal.

New in version 2.4.

interaction

The interaction that was responded to.

Type:

ModalInteraction

LocalizationKeyError

exception disnake.LocalizationKeyError(key)[source]

Exception that’s raised when a localization key lookup fails.

New in version 2.5.

key

The localization key that couldn’t be found.

Type:

str

OpusError

exception disnake.opus.OpusError(code)[source]

An exception that is thrown for libopus related errors.

code

The error code returned.

Type:

int

OpusNotLoaded

exception disnake.opus.OpusNotLoaded[source]

An exception that is thrown for when libopus is not loaded.

Exception Hierarchy

Warnings

DiscordWarning

class disnake.DiscordWarning[source]

Base warning class for disnake.

New in version 2.3.

ConfigWarning

class disnake.ConfigWarning[source]

Warning class related to configuration issues.

New in version 2.3.

SyncWarning

class disnake.SyncWarning[source]

Warning class for application command synchronization issues.

New in version 2.3.

LocalizationWarning

class disnake.LocalizationWarning[source]

Warning class for localization issues.

New in version 2.5.

Warning Hierarchy