Skip to main content

A simple interaction handler for discord.py.

Project description

<br>

<a href="https://pypi.org/project/discord-py-slash-command/"><img src="https://raw.githubusercontent.com/eunwoo1104/discord-py-slash-command/master/.github/discordpyslashlogo.png" alt="discord-py-slash-command" height="128"></a>

<h2 align = "center">A simple discord slash command handler for <a href="https://github.com/Rapptz/discord.py">discord.py</a></h2>

    <a href="https://app.codacy.com/gh/eunwoo1104/discord-py-slash-command?utm_source=github.com&utm_medium=referral&utm_content=eunwoo1104/discord-py-slash-command&utm_campaign=Badge_Grade_Settings"><img src="https://api.codacy.com/project/badge/Grade/224bdbe58f8f43f28a093a33a7546456" alt="Codacy Badge"></a>

    <a href="https://discord.gg/KkgMBVuEkx"> <img alt="Discord" src="https://img.shields.io/discord/789032594456576001"></a>

About ⦿

Installation ⦿

Examples ⦿

Documentation ⦿

Discord Server

About

Discord Slash Commands are a new implementation for the Bot API that utilize the forward-slash "/" symbol.

Released on 15 December 2020, many bot developers are still learning to learn how to implement this into

their very own bots. This command handler aims to help serve as a guidance for those looking into wanting to add

these new slash commands into their bots for those that use discord.py, building off of the current library

code and substituting its own for where it's needed. discord-py-slash-command stands as the first public

slash command handler library to be made for Discord Bot API libraries.

Installation

You are able to easily install the discord-py-slash-command library by using the given PIP line below:

pip install -U discord-py-slash-command

Examples

Quick Startup

This is a quick startup method towards using slash commands.

import discord

from discord.ext import commands

from discord_slash import SlashCommand, 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")

Advanced

This offers implementation of the slash command library in the usage of a cog.

# bot.py

from discord.ext import commands

from discord_slash import SlashCommand



bot = commands.Bot(command_prefix="prefix")

slash = SlashCommand(bot, sync_commands=True, sync_on_cog_reload=True)



bot.load_extension("cog")

bot.run("TOKEN")



# cog.py

import discord

from discord.ext import commands

from discord_slash import cog_ext, SlashContext



class Slash(commands.Cog):

    def __init__(self, bot):

        self.bot = bot



    @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))

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-2.0.2.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

discord_py_slash_command-2.0.2-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: discord-py-slash-command-2.0.2.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for discord-py-slash-command-2.0.2.tar.gz
Algorithm Hash digest
SHA256 c4258b8395a3a017c2471aa3fde6a3bc9c3bf7cc8972d04d89ed882868f949ed
MD5 b59ff0e30fec70a874881f77a173dffb
BLAKE2b-256 e5660521f3230d222bf2b7d08b4ed0ca19af42f841732e82eee6470196420c14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: discord_py_slash_command-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for discord_py_slash_command-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2bcbc9f0c52d7fb576eb6c5cf36b231050b56cb78045a641906e60b68ff6174
MD5 804a69afb113ec042a69d5e849fd6ece
BLAKE2b-256 15925ee8e78d34dafc3cb108ef15aec978ddd36af792a3d1700644d82a521ee3

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