A discord.py extension module to facilitate class-based creation of application commands.
Project description
An extension module for discord.py that facilitates class-based creation of Discord application commands.
Credits
discord.py: Docs and various code snippets.
IAmTomahawkx: Initial idea and design.
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.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file discord-class-commands-1.1.0.tar.gz
.
File metadata
- Download URL: discord-class-commands-1.1.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 662d27ad58a7153437d56f24fb10c8c2eb49f1ad0d9382b750da8c9fe7821eb7 |
|
MD5 | 43775daed6aaf3b54e99a9185b28ed58 |
|
BLAKE2b-256 | 3ac28aa5c07ee78a8aa0ad266a5d6d3e907c11b409d727f83b9b52cebefa7b0d |
File details
Details for the file discord_class_commands-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: discord_class_commands-1.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a49ed433d8373f539bd4925165201d35effbc33d56a5b2538c0eb98dd1f33734 |
|
MD5 | ce7f65cf11ce235fba0c0e087c95600b |
|
BLAKE2b-256 | 4c2f4113823fd24e3b427c8301d098141fb6ca70fb020f2dbba073379b5f4ce0 |