Skip to content

Commit 5af5556

Browse files
committed
Code explanation with comments.
1 parent 9a2a26b commit 5af5556

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/app_commands/slash_cog.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from discord.ext import commands
2-
from discord.commands import slash_command
2+
from discord.commands import slash_command # Importing the decorator that makes slash commands.
33

44
class Example(commands.Cog):
55
def __init__(self, bot):
66
self.bot = bot
77

8-
@slash_command()
9-
async def example(self, ctx):
8+
@slash_command(guild_ids=[...]) # Create a slash command for the supplied guilds.
9+
async def hello(self, ctx):
1010
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!")
1116

1217
def setup(bot):
1318
bot.add_cog(Example(bot))

0 commit comments

Comments
 (0)