We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 26c85e4 + 5af5556 commit e3bde55Copy full SHA for e3bde55
examples/app_commands/slash_cog.py
@@ -0,0 +1,18 @@
1
+from discord.ext import commands
2
+from discord.commands import slash_command # Importing the decorator that makes slash commands.
3
+
4
+class Example(commands.Cog):
5
+ def __init__(self, bot):
6
+ self.bot = bot
7
8
+ @slash_command(guild_ids=[...]) # Create a slash command for the supplied guilds.
9
+ async def hello(self, ctx):
10
+ await ctx.respond("Hi, this is a slash command from a cog!")
11
12
13
+ @slash_command() # Not passing in guild_ids creates a global slash command (might take an hour to register).
14
+ async def hi(self, ctx):
15
+ await ctx.respond(f"Hi, this is a global slash command from a cog!")
16
17
+def setup(bot):
18
+ bot.add_cog(Example(bot))
0 commit comments