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 2
2
Simple Discord Slash Command extension for [ discord.py] ( https://github.com/Rapptz/discord.py ) .
3
3
4
4
## Example
5
+ Normal usage:
5
6
``` py
6
7
import discord
7
8
from discord.ext import commands
@@ -21,6 +22,33 @@ async def _test(ctx: SlashContext):
21
22
bot.run(" discord_token" )
22
23
```
23
24
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
+
24
52
## Installation
25
53
` pip install -U discord-py-slash-command `
26
54
You can’t perform that action at this time.
0 commit comments