Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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.

Metadata

Release files for discord-ext-slash 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discord-ext-slash 0.9.2
File Size Uploaded
discord-ext-slash-0.9.2.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for discord-ext-slash 0.9.2
File Interpreter ABI Platform
discord_ext_slash-0.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.2 kB

Release files / discord-ext-slash-0.9.2.tar.gz

Download URL discord-ext-slash-0.9.2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c692633ef8c6ac56cd81388822aabe5b3f36f73fa1a4e784e14f03ca9671ffab
BLAKE2b-256 checksum
How to use checksums
dc50e7d7c4078e061cb53a85f1e2aee9e2846cdc28ce30887b4df27c7cb84cd1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / discord_ext_slash-0.9.2-py3-none-any.whl

Download URL discord_ext_slash-0.9.2-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfb4b7be91c8bfce6566e89c9c47099d06b5ce8fe7f00ddc74e6b0bd4d3dcbc1
BLAKE2b-256 checksum
How to use checksums
52462f27d8ccfda238484da56b02ceea7ccf5ce0f18bc99a1b770d414fa1d2be
Upload date
Uploaded using Trusted Publishing?
What is 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
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page