API Reference

The full API Reference can be found by viewing the individual pages in the sidebar or by scrolling to the bottom of this page.

Logging Configuration

Note

This module uses the Python logging module to log diagnostic and errors in an output independent way. If the logging module is not configured, these logs will not be output anywhere. See Setting Up Logging for more information on how to set up and use the logging module with disnake.

Abstract Base Classes

An abstract base class (also known as an abc) is a class that models can inherit to get their behaviour. Abstract base classes should not be instantiated. They are mainly there for usage with isinstance() and issubclass().

This library has a module related to abstract base classes, in which all the ABCs are subclasses of typing.Protocol - Abstract Base Classes.

Discord Models

Models are classes that are received from Discord and are not meant to be created by the user of the library.

Danger

Classes marked as models are not intended to be created by users and are also read-only.

For example, this means that you should not make your own User instances nor should you modify the User instance yourself.

If you want to get one of these model classes instances they’d have to be through the cache, and a common way of doing so is through the utils.find() function or attributes of model classes that you receive from the Events.

Note

Nearly all models have __slots__ defined which means that it is impossible to have dynamic attributes on them.

Data Classes

Some classes are just there to be data containers. We call them data classes.

Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes.

Nearly all data classes have __slots__ defined which means that it is impossible to have dynamic attributes on them.

The only exception to this rule is Object, which is made with dynamic attributes in mind.

Enumerations

The API provides some enumerations for certain types of values to avoid the API from being typed as literals in case the values change in the future.

All enumerations are subclasses of an internal class which mimics the behaviour of enum.Enum.

Documents