Support slash commands with discord.py.
Project description
Support slash commands.
Example Usage
from discord.ext import slash
client = slash.SlashBot(
# normal arguments to commands.Bot()
command_prefix='.', description="whatever",
# special option: modify all global commands to be
# actually guild commands for this guild instead,
# for the purposes of testing. Remove this argument
# or set it to None to make global commands be
# properly global - note that they take 1 hour to
# propagate. Useful because commands have to be
# re-registered if their API definitions are changed.
debug_guild=staging_guild_id
)
msg_opt = slash.Option(
# description of option, shown when filling in
description='Message to send',
# this means that the slash command will not be invoked
# if this argument is not specified
required=True)
@client.slash_cmd() # global slash command
async def repeat( # command name
ctx: slash.Context, # there MUST be one argument annotated with Context
message: msg_opt
):
"""Make the bot repeat what you say""" # description of command
# respond to the interaction, must be done within 3 seconds
await ctx.respond(message) # string (or str()able) message
client.run(token)
Notes
discord.ext.slash.Context emulates discord.ext.commands.Context, but only to a certain extent. Notably, ctx.message does not exist, because slash commands can be run completely without the involvement of messages. However, channel and author information is still available.
All descriptions are required.
You must grant the bot applications.commands permissions in the OAuth2 section of the developer dashboard.
See the docs.
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
discord-ext-slash-0.8.1.tar.gz
(17.0 kB
view details)
Built Distribution
File details
Details for the file discord-ext-slash-0.8.1.tar.gz
.
File metadata
- Download URL: discord-ext-slash-0.8.1.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b705b001cc7515cef638a9dc2cb3ff83a0fd1de3e5f3acf46ebd8dccb7c8d4bc |
|
MD5 | 0ecda1a4bb2eedae7d2bd77681ca2879 |
|
BLAKE2b-256 | bec4f879e1bd773e8f0696d4e07b85d94b2b1ee21b847bdf292b16993bdea9a8 |
Provenance
File details
Details for the file discord_ext_slash-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: discord_ext_slash-0.8.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3517c3f6a2da173f99b048ab6eb60714717165d581294022757295825dd83b47 |
|
MD5 | d224d19dfa2a47d277d5109f19aa95ef |
|
BLAKE2b-256 | c1cc1f75d5cdbb3dbc4fa97ac30b03d3029c6c58b9268f6d960c02f380c1b505 |