or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

application-commands.mdautomod.mdchannels-messaging.mdclient-bot.mdcommand-framework.mderror-handling.mdevents-gateway.mdguild-management.mdindex.mdinteractions-ui.mdlocalization-i18n.mdpermissions-security.mdpolls.mdusers-members.mdvoice-audio.md
tile.json

tessl/pypi-disnake

A modern, easy-to-use, feature-rich async-ready API wrapper for Discord written in Python

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/disnake@2.10.x

To install, run

npx @tessl/cli install tessl/pypi-disnake@2.10.0

index.mddocs/

Disnake

A modern, easy-to-use, feature-rich, and async-ready API wrapper for Discord written in Python. Disnake enables developers to create Discord bots and applications with proper rate limit handling, type-safety measures, and FastAPI-like slash command syntax while preserving the syntax and structure of discord.py 2.0.

Package Information

  • Package Name: disnake
  • Language: Python
  • Installation: pip install disnake
  • Voice Support: pip install disnake[voice]

Core Imports

import disnake

Common imports for bot development:

from disnake.ext import commands
import disnake

Basic Usage

import disnake
from disnake.ext import commands

# Create a bot with message commands
bot = commands.Bot(command_prefix='!')

@bot.event
async def on_ready():
    print(f'Bot is ready! Logged in as {bot.user}')

@bot.slash_command(description="Say hello")
async def hello(inter: disnake.ApplicationCommandInteraction):
    await inter.response.send_message("Hello!")

@bot.command()
async def ping(ctx):
    await ctx.send('Pong!')

# Run the bot
bot.run('YOUR_BOT_TOKEN')

Architecture

Disnake follows a hierarchical event-driven architecture:

  • Client/Bot: Central connection handler managing Discord API communication
  • Gateway: WebSocket connection for real-time events and command handling
  • Commands: Both traditional message-based and modern application commands (slash commands, context menus)
  • Interactions: User input handling through buttons, select menus, modals, and application commands
  • Entities: Discord objects (guilds, channels, users, messages) with full API integration
  • Extensions: Modular command framework with cogs and extensions for organized bot structure

This design provides both backward compatibility with discord.py and modern Discord API features including interactions, UI components, and comprehensive bot development tools.

Capabilities

Client and Bot Classes

Core client and bot classes for establishing Discord connections and managing bot functionality. Includes both basic clients and specialized bot classes for different use cases.

class Client:
    def __init__(self, **options): ...
    async def login(self, token: str): ...
    async def connect(self, *, reconnect: bool = True): ...
    def run(self, token: str, **kwargs): ...
    async def close(): ...

class Bot(commands.BotBase, Client):
    def __init__(self, command_prefix, **options): ...

Client and Bot Classes

Channels and Messaging

Comprehensive channel types and messaging functionality supporting text channels, voice channels, threads, forums, and direct messages. Includes message creation, editing, deletion, and rich content support.

class TextChannel:
    async def send(self, content=None, **kwargs) -> Message: ...
    async def fetch_message(self, id: int) -> Message: ...

class Message:
    content: str
    author: Union[User, Member]
    channel: Messageable
    async def edit(self, **kwargs): ...
    async def delete(): ...

Channels and Messaging

Application Commands

Modern Discord application commands including slash commands, user context menu commands, and message context menu commands with parameter validation and autocomplete support.

def slash_command(name=None, description=None, **kwargs):
    """Decorator for slash commands"""

def user_command(name=None, **kwargs):
    """Decorator for user context menu commands"""

def message_command(name=None, **kwargs):
    """Decorator for message context menu commands"""

Application Commands

Interactions and UI Components

Interactive Discord UI elements including buttons, select menus, modals, and views for creating rich user interfaces with persistent component handling.

class View:
    def __init__(self, **kwargs): ...
    async def interaction_check(self, interaction: Interaction) -> bool: ...

class Button(Item):
    def __init__(self, style=ButtonStyle.secondary, label=None, **kwargs): ...
    async def callback(self, interaction: Interaction): ...

class Modal:
    def __init__(self, title: str, **kwargs): ...
    async def on_submit(self, interaction: ModalInteraction): ...

Interactions and UI Components

Guild Management

Comprehensive guild (server) management including member management, role management, channel organization, permissions, and guild-specific features like scheduled events and moderation.

class Guild:
    name: str
    members: List[Member]
    channels: List[GuildChannel]
    roles: List[Role]
    async def create_text_channel(self, name: str, **kwargs) -> TextChannel: ...
    async def ban(self, user, **kwargs): ...

Guild Management

Users and Members

User and member objects representing Discord users and guild members with profile information, permissions, voice states, and user-specific operations.

class User:
    id: int
    name: str
    discriminator: str
    avatar: Optional[Asset]

class Member(User):
    guild: Guild
    roles: List[Role]
    joined_at: Optional[datetime]
    async def add_roles(*roles): ...

Users and Members

Events and Gateway

Discord gateway events and event handling system for real-time bot functionality including message events, member events, guild events, and custom event dispatching.

@bot.event
async def on_ready(): ...

@bot.event
async def on_message(message: Message): ...

@bot.event
async def on_member_join(member: Member): ...

Events and Gateway

Command Framework

Traditional message-based command framework with command groups, argument parsing, permission checks, cooldowns, and error handling for text-based bot commands.

@commands.command()
async def my_command(ctx: commands.Context): ...

@commands.group()
async def my_group(ctx: commands.Context): ...

@commands.check(lambda ctx: ctx.author.id == 123456789)
async def owner_only(ctx): ...

Command Framework

Permissions and Security

Discord permissions system, role management, and security features including permission overrides, role hierarchy, and access control for commands and features.

class Permissions:
    def __init__(self, **kwargs): ...
    @classmethod
    def all(cls): ...
    @classmethod
    def none(cls): ...

class PermissionOverwrite:
    def __init__(self, **kwargs): ...

Permissions and Security

Error Handling

Comprehensive error handling system covering Discord API errors, command framework errors, interaction errors, and custom exception types with proper error recovery patterns.

class DiscordException(Exception): ...
class HTTPException(DiscordException): ...
class CommandError(DiscordException): ...
class InteractionException(DiscordException): ...

@bot.event
async def on_command_error(ctx, error): ...

Error Handling

Voice and Audio

Voice channel connection, audio streaming, and voice-related functionality for music bots and voice applications with proper audio handling and connection management.

class VoiceChannel:
    async def connect(self, **kwargs) -> VoiceClient: ...

class VoiceClient:
    async def disconnect(): ...
    def play(self, source, **kwargs): ...

Voice and Audio

Localization and Internationalization

Comprehensive i18n system for application commands with support for Discord's native localization features, file-based translation stores, and custom localization providers.

class Localized:
    def __init__(self, string, *, key=None, **localizations): ...
    def set(self, locale, value): ...

class LocalizationStore(LocalizationProtocol):
    def __init__(self, files, *, strict=False, fallback=None): ...
    async def get(self, key, locale, **kwargs): ...

Localization and Internationalization

AutoMod System

Discord's automated content moderation system with configurable rules, triggers, and actions for filtering messages, managing spam, and enforcing community guidelines.

class AutoModRule:
    @property
    def name(self) -> str: ...
    @property
    def trigger_type(self) -> AutoModTriggerType: ...
    async def edit(self, **kwargs) -> AutoModRule: ...
    async def delete(self) -> None: ...

class AutoModAction:
    @property
    def type(self) -> AutoModActionType: ...

AutoMod System

Poll System

Discord's native poll system with multi-choice answers, emoji support, vote tracking, and automatic result counting for interactive community engagement.

class Poll:
    @property
    def question(self) -> PollMedia: ...
    @property
    def answers(self) -> List[PollAnswer]: ...
    async def end(self) -> Message: ...
    
    @classmethod
    def create(cls, question, *answers, duration=None, allow_multiselect=False): ...

class PollAnswer:
    @property
    def vote_count(self) -> int: ...
    def get_voters(self) -> PollAnswerIterator: ...

Poll System