Subcommands in Cog #403
-
What's the cleanest way to get a subcommand for a slash command in a Cog? For example, in the Cog Example, is there a good way to add a subcommand to class FooCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
parent_command = bot.slash_command(name="Foo", guild_ids=[GUILD_ID])(self.foo)
parent_command.subcommand(name="bar")(self.bar)
async def foo(self, interaction: Interaction):
pass
async def bar(self, interaction: Interaction):
await interaction.send("Hello, World") |
Beta Was this translation helpful? Give feedback.
Answered by
DenverCoder1
Feb 11, 2022
Replies: 1 comment 2 replies
-
It should work just like subcommands outside a cog class TestCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@nextcord.slash_command(guild_ids=[TESTING_GUILD_ID], description="test")
async def test_slash_command(self, interaction: nextcord.Interaction):
pass
@test_slash_command.subcommand(description="subcommand")
async def subcommand(self, interaction: nextcord.Interaction):
await interaction.send("subcommand") |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
zuhairp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should work just like subcommands outside a cog