Skip to content

Commit 03ef4aa

Browse files
authored
Added an example for slash commands in cogs.
1 parent 9496c72 commit 03ef4aa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

examples/app_commands/slash_cog.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from discord.ext import commands
2+
from discord.commands import slash_command
3+
4+
class Example(commands.Cog):
5+
def __init__(self, bot):
6+
self.bot = bot
7+
8+
@slash_command()
9+
async def example(self, ctx):
10+
await ctx.respond("Hi, this is a slash command from a cog!")
11+
12+
def setup(bot):
13+
bot.add_cog(Example(bot))

0 commit comments

Comments
 (0)