-
What is the proper way to create application commands inside a cog ( |
Beta Was this translation helpful? Give feedback.
Answered by
LostLuma
Aug 23, 2022
Replies: 1 comment 12 replies
-
You can create commands inside cogs by simply defining them inside and adding the @discord.app_commands.command()
async def upload(interaction: discord.Interaction, file: discord.Attachment) -> None:
...
class Example(commands.Cog):
@discord.app_commands.command()
async def upload(interaction: discord.Interaction, file: discord.Attachment) -> None:
.... When the cog is loaded it will be added to the bot's command tree, and you will be able to use and sync it just like all other app commands. |
Beta Was this translation helpful? Give feedback.
12 replies
Answer selected by
hitblast
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create commands inside cogs by simply defining them inside and adding the
self
argument, similarly to how it works in the commands extension:When the cog is loaded it will be added to the bot's command tree, and you will be able to use and sync it just like all other app commands.