Skip to main content

A Python wrapper for the Discord API

Project description

Disnake Banner

disnake

Discord server invite PyPI version info PyPI supported Python versions Commit activity

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

Key Features

  • Proper rate limit handling.
  • Type-safety measures.
  • FastAPI-like slash command syntax.

The syntax and structure of discord.py 2.0 is preserved.

Installing

Python 3.8 or higher is required.

To install the library without full voice support, you can just run the following command:

# Linux/macOS
python3 -m pip install -U disnake

# Windows
py -3 -m pip install -U disnake

Installing disnake with full voice support requires you to replace disnake here, with disnake[voice]. To learn more about voice support (or installing the development version), please visit this section of our guide.

(You can optionally install PyNaCl for voice support.)

Note that voice support on Linux requires installation of libffi-dev and python-dev packages, via your preferred package manager (e.g. apt, dnf, etc.) before running the following commands.

Versioning

This project does not quite follow semantic versioning; for more details, see version guarantees.

To be on the safe side and avoid unexpected breaking changes, pin the dependency to a minor version (e.g. disnake==a.b.* or disnake~=a.b.c) or an exact version (e.g. disnake==a.b.c).

Quick Example

Slash Commands Example

import disnake
from disnake.ext import commands

bot = commands.InteractionBot(test_guilds=[12345])

@bot.slash_command()
async def ping(inter):
    await inter.response.send_message("Pong!")

bot.run("BOT_TOKEN")

Context Menus Example

import disnake
from disnake.ext import commands

bot = commands.InteractionBot(test_guilds=[12345])

@bot.user_command()
async def avatar(inter, user):
    embed = disnake.Embed(title=str(user))
    embed.set_image(url=user.display_avatar.url)
    await inter.response.send_message(embed=embed)

bot.run("BOT_TOKEN")

Prefix Commands Example

import disnake
from disnake.ext import commands

bot = commands.Bot(command_prefix=commands.when_mentioned)

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

bot.run("BOT_TOKEN")

You can find more examples in the examples directory.


DocumentationGuideDiscord ServerDiscord Developers


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disnake-2.7.0.tar.gz (973.9 kB view hashes)

Uploaded Source

Built Distribution

disnake-2.7.0-py3-none-any.whl (1.0 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page