Skip to main content

Simple Discord Slash Command extension for discord.py.

Project description

discord-py-slash-command

Simple Discord Slash Commands extension for discord.py.

Example

Normal usage:

import discord
from discord.ext import commands
from discord_slash import SlashCommand
from discord_slash import SlashContext

bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
slash = SlashCommand(bot)


@slash.slash(name="test")
async def _test(ctx: SlashContext):
    embed = discord.Embed(title="embed test")
    await ctx.send(content="test", embeds=[embed])


bot.run("discord_token")

Cog:

import discord
from discord.ext import commands
from discord_slash import cog_ext
from discord_slash import SlashCommand
from discord_slash import SlashContext


class Slash(commands.Cog):
    def __init__(self, bot):
        if not hasattr(bot, "slash"):
            # Creates new SlashCommand instance to bot if bot doesn't have.
            bot.slash = SlashCommand(bot, override_type=True)
        self.bot = bot
        self.bot.slash.get_cog_commands(self)

    def cog_unload(self):
        self.bot.slash.remove_cog_commands(self)

    @cog_ext.cog_slash(name="test")
    async def _test(self, ctx: SlashContext):
        embed = discord.Embed(title="embed test")
        await ctx.send(content="test", embeds=[embed])


def setup(bot):
    bot.add_cog(Slash(bot))

Installation

pip install -U discord-py-slash-command

Simple note before you use this

Since slash commands are currently not officially released (They're in public beta), there will be many breaking changes to this extension which may cause it to become unstable, so I'd recommend waiting until discord officially releases slash commands, and waiting until Release 1.1.0, which I'm planning to finish implementing most of the features.
Or you can wait until discord.py supports slash commands.

DOCS

https://discord-py-slash-command.readthedocs.io/en/latest/
See discord-api-docs for some more information about some formats.

Any Questions?

Discord Server
Or you can ask at Discussions.

TODO

  • Rewrite http.py and webhook part (Maybe use discord.py's webhook support?)
  • Try supporting most of the features supported by discord.py commands extension

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-py-slash-command-1.0.7.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

discord_py_slash_command-1.0.7-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file discord-py-slash-command-1.0.7.tar.gz.

File metadata

  • Download URL: discord-py-slash-command-1.0.7.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for discord-py-slash-command-1.0.7.tar.gz
Algorithm Hash digest
SHA256 9e3c4b0afbf86f47cc9780e461a02691cf4c71b9e6f0823ed8b2270c00b1cf2b
MD5 1bf438e549aa9938365a6746fb5c14fc
BLAKE2b-256 35c0f835cb038aa50714d4372d026cec406c7d6fefdf23fdf543d6a7bd931561

See more details on using hashes here.

File details

Details for the file discord_py_slash_command-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: discord_py_slash_command-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for discord_py_slash_command-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 dced6ad336c4d47e1acb7d526de2937e916e7bb964078297a12c3d7e4f26d474
MD5 c07bc11ec1f14afcdae926eebea45621
BLAKE2b-256 aecd0a2fea52a8cc5b1d7041c9593be692253e812344cf202dad352276ce18db

See more details on using hashes here.

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