File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 22Simple Discord Slash Command extension for [ discord.py] ( https://github.com/Rapptz/discord.py ) .
33
44## Example
5+ Normal usage:
56``` py
67import discord
78from discord.ext import commands
@@ -21,6 +22,33 @@ async def _test(ctx: SlashContext):
2122bot.run(" discord_token" )
2223```
2324
25+ Cog:
26+ ``` py
27+ import discord
28+ from discord.ext import commands
29+ from discord_slash import SlashCommand
30+ from discord_slash import SlashContext
31+
32+
33+ class Slash (commands .Cog ):
34+ def __init__ (self , bot ):
35+ self .bot = bot
36+ self .slash = SlashCommand(bot, override_type = True )
37+ # Cog is only supported by commands ext, so just skip checking type.
38+
39+ @self.slash.slash (name = " test" )
40+ async def _test (ctx : SlashContext):
41+ await ctx.send(content = " Hello, World!" )
42+
43+ def cog_unload (self ):
44+ self .slash.remove()
45+
46+
47+ def setup (bot ):
48+ bot.add_cog(Slash(bot))
49+
50+ ```
51+
2452## Installation
2553` pip install -U discord-py-slash-command `
2654
You can’t perform that action at this time.
0 commit comments