Simple Discord Slash Command extension for discord.py.
Project description
discord-py-slash-command
Simple Discord Slash Command extension for discord.py.
Example
Normal usage:
import discord
from discord.ext import commands
from discord_slash import SlashCommand
from discord_slash.model 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(Not Recommended):
import discord
from discord.ext import commands
from discord_slash import SlashCommand
from discord_slash import SlashContext
class Slash(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.slash = SlashCommand(bot, override_type=True)
# Cog is only supported by commands ext, so just skip checking type.
# Make sure all commands should be inside `__init__`
# or some other functions that can put commands.
@self.slash.slash(name="test")
async def _test(ctx: SlashContext):
await ctx.send(content="Hello, World!")
def cog_unload(self):
self.slash.remove()
def setup(bot):
bot.add_cog(Slash(bot))
Installation
pip install -U discord-py-slash-command
Simple note before you use this
Since slash command feature is not officially released,
there will be many breaking changes to this extension and may be unstable,
so I'd recommend waiting until discord officially releases slash command,
and wait until Release 1.1.0, which I'm planning to finish implementing most of the feature.
Or you can wait until discord.py supports slash command.
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
- Support subcommands
- Try supporting most of the features supported by discord.py commands extension
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-py-slash-command-1.0.4.1.tar.gz
.
File metadata
- Download URL: discord-py-slash-command-1.0.4.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2cdfb9763393acdcd22153a94a75a49280b83eefdd7dfdd43b24ea582aac409 |
|
MD5 | 7270e5cfebd21b2e52600666b8e6266a |
|
BLAKE2b-256 | 82d9fda1c0afbbd065a14e0b5188b15dada9dbe9fa85ecd677adc79c9ef4bba6 |
File details
Details for the file discord_py_slash_command-1.0.4.1-py3-none-any.whl
.
File metadata
- Download URL: discord_py_slash_command-1.0.4.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa554e2f72789b6d6a3bb9657228454818f4b2e435e36a76819af78229436418 |
|
MD5 | f4c511d3a6df85aaddb555ebd860ff78 |
|
BLAKE2b-256 | 1d17221cbe6ea360ab6b978ad810108b2f2168897d27f45a12ef233faa1b8d96 |