Added Cog example
Simple Discord Slash Command extension for [discord.py](https://github.com/Rapptz/discord.py).
## Example
+Normal usage:
```py
import discord
from discord.ext import commands
@@ -21,6 +22,33 @@ async def _test(ctx: SlashContext):
bot.run("discord_token")
```
+Cog:
+```py
+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.
+
+ @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`
