Skip to main content

A discord.py extension module to facilitate class-based creation of application commands.

Project description

Discord server invite PyPI version info PyPI supported Python versions

An extension module for discord.py that facilitates class-based creation of Discord application commands.

Credits

Key Features

  • Modern Pythonic API using async and await.

  • Proper rate limit handling.

  • Optimised in both speed and memory.

  • Fully compatible with discord.py’s application command implementation without monkey-patching.

Installing

Python 3.8 or higher is required

To install the extension, you can just run the following command:

# Linux/macOS
python3 -m pip install -U discord-class-commands

# Windows
py -3 -m pip install -U discord-class-commands

To install the development version, do the following:

$ git clone https://github.com/dolfies/discord-class-commands
$ cd discord.py
$ python3 -m pip install -U .

This extension depends on version 2.0 of discord.py or a compatible fork.

Quick Example

import discord
from discord.ext import class_commands

client = discord.Client(intents=discord.Intents.default())
tree = discord.app_commands.CommandTree(client)

@client.event
async def setup_hook():
    await tree.sync()

class Ping(class_commands.SlashCommand):
    async def callback(self):
        await self.send(f'Pong!')

tree.add_command(Ping)
client.run('token')

You can find more examples in the examples directory.

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

discord-class-commands-1.1.0.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

discord_class_commands-1.1.0-py3-none-any.whl (13.5 kB 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