Skip to main content

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 are
    # re-registered every time the bot starts.
    debug_guild=7293012031203012
)

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
):
    """Send a message in the bot's name""" # description of command
    await ctx.respond(message, # respond to the interaction
        # sends a message without showing the command invocation
        rtype=slash.InteractionResponseType.ChannelMessage)

client.run(token)

Notes

  • slash.Context emulates 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.

See the wiki.

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-ext-slash-0.1.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

discord_ext_slash-0.1.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file discord-ext-slash-0.1.2.tar.gz.

File metadata

  • Download URL: discord-ext-slash-0.1.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 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

Hashes for discord-ext-slash-0.1.2.tar.gz
Algorithm Hash digest
SHA256 62525912e71bbf4642ff3099462cb2e2f278c493d7660e85d796c7db4c3bd93d
MD5 83a3c2834bbb73a1bc797d617e2836ae
BLAKE2b-256 7ddbbde9c1ec46fb48884191eb5506eae32d669c556043397f937c4ddf71c1e3

See more details on using hashes here.

Provenance

File details

Details for the file discord_ext_slash-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: discord_ext_slash-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 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

Hashes for discord_ext_slash-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5cd24244a689f104be0cd71e3c7edd77d6f20f98a46b2bd014e7310d2333aa72
MD5 eb907d876405e19a9e6dbecef843a632
BLAKE2b-256 5a41ab7263a312a76e9cd256b8a3d0474560355ac5191240654a513ec9e640ad

See more details on using hashes here.

Provenance

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