disnake Documentation

repository·master·Indexed 21 days ago

https://github.com/disnakedev/disnake

A modern, async-ready, and feature-rich Python API wrapper for Discord. It provides type-safety, proper rate limit handling, and a FastAPI-like syntax for slash commands while preserving the structure of discord.py 2.0. Requires Python 3.10 or higher.

Tokens
108.6K
Snippets
306
Records
625
Agent score
72%

What's inside disnake

  1. Overview of disnake features

    master

    disnake is a modern, async-ready API wrapper for Discord designed for ease of use and performance. Key features include:

    • Modern Pythonic API: Utilizes async/await syntax throughout.
    • Sane Rate Limit Handling: Built-in mechanisms to prevent 429 Too Many Requests errors.
    • Command Extension: A dedicated extension to simplify bot command creation.
    • Object-Oriented Design: Easy to use with intuitive object structures.
    • Optimized Performance: Designed for high speed and low memory usage.
  2. Use disnake.ext.commands for bot command frameworks

    master
    While the core disnake library provides low-level interaction with Discord, disnake.ext.commands is an extension library designed to simplify bot development. It provides a high-level, extensible, and flexible framework for creating bot commands, preventing the need to manually implement a command handling system.
  3. Use disnake.utils for common utility functions

    master
    The disnake.utils module provides a collection of public utility functions for common tasks such as time manipulation, string formatting, Discord-specific escaping, and data chunking. These functions are designed to simplify common operations when building Discord bots.
  4. What is a Bot in disnake.ext.commands

    master
    In disnake.ext.commands, a Bot is a specialized subclass of disnake.Client designed to streamline and simplify the development of application commands (Slash Commands, User Commands, and Message Commands) and prefix commands. While a standard Client handles raw gateway events, a Bot provides high-level abstractions for command registration, command checks, and command lifecycle hooks.
  5. Understand Discord Integrations in disnake

    master
    Integrations are special entities that are integrated into a Guild. These typically represent external services or applications connected to a Discord server, such as bots or Twitch/YouTube integrations. In disnake, these are represented by various model classes that allow you to inspect the state and type of the integration within a guild.
  6. Understand disnake's versioning guarantees

    master

    disnake does not strictly follow semantic versioning. Because the underlying Discord API is dynamic and can introduce breaking changes, disnake may introduce breaking changes during minor version bumps, not just major ones.

    The versioning scheme follows major.minor.micro:

    • major: Significant refactoring or large changes (likely includes breaking changes).
    • minor: New features, fixes, and may include breaking changes.
    • micro: Fixes only; no new features and no breaking changes.

    Important: Breaking changes are always explicitly marked in the whats_new documentation. To avoid breakage, only rely on publicly documented functions and classes. Any attribute starting with an underscore (_) or any undocumented function/class is considered internal and subject to change without notice.

  7. Understand Abstract Base Classes in disnake

    master
    In disnake, Abstract Base Classes (ABCs) are used as templates for other classes. You can inherit from these classes to either adopt specific behaviors or override them to implement custom logic. They define the interface and expected structure for core entities like Users, Channels, and Messages.
  8. Preliminary Support for Text-in-Voice

    master

    Disnake provides preliminary support for the 'text-in-voice' feature. Note that this feature is currently limited to a small number of servers and the API is still evolving.

    Key Details

    • VoiceChannel Capabilities: VoiceChannel now inherits from abc.Messageable. It includes properties like .nsfw, .slowmode_delay, .last_message_id, and .last_message, and methods like .is_nsfw() and .get_partial_message().
    • Limitations: Text-in-voice currently does not support threads, webhooks, nsfw flags, or slowmode. The nsfw and slowmode_delay parameters for VoiceChannel.edit are currently supported by the API but may change.
    • Warning: Expect breaking changes as the Discord API for this feature matures.
  9. Handle Guild and Channel Audit Log changes

    master

    When auditing changes to guilds or channels, use the AuditLogDiff object to inspect what specifically changed.

    For guild_update, possible diff attributes include:

    • afk_channel, system_channel, afk_timeout, name, owner, icon, banner, vanity_url_code, etc.

    For channel_create or channel_update, possible diff attributes include:

    • name, type, topic, bitrate, user_limit, slowmode_delay, nsfw, etc.

    For overwrite_create, overwrite_update, or overwrite_delete, possible diff attributes include:

    • allow, deny, id, type (Note: type is an int as of version 2.6).
  10. Work with Discord SKUs in disnake

    master
    SKUs (Stock Keeping Units) represent items being sold on Discord, such as application subscriptions. In disnake, you can interact with these via the SKU model, SKUFlags data class, and SKUType enumeration. For a high-level understanding of how monetization works on Discord, refer to the official Discord documentation.
  11. How to use Discord Message Components in disnake

    master

    Message components allow you to create interactive UIs directly within Discord messages.

    Important Distinction: The classes documented in the disnake.components module (such as Button, SelectMenu, ActionRow, etc.) are Discord Models. They are intended to represent the data received from the Discord API when a user interacts with a component.

    Do not attempt to instantiate these classes directly to send them to Discord.

    To create and send interactive components (like buttons or menus) in your bot, you should use the Bot UI Kit instead. The UI Kit provides constructible versions of these components designed for building and sending UIs.