EpicEfeathers
EpicEfeathers

Reputation: 126

discord.py invoke subcommand

Basically I want to invoke a subcommand. If I have this code here, with fun being the subcommand:

@client.group()
async def help(ctx):
    if ctx.invoked_subcommand is None:
        await ctx.send("Hello")
@help.command()
async def fun(ctx):
    if ctx.invoked_subcommand is None:
        await ctx.send("Fun")

I want to have another command, for example: async def invoke_fun(ctx), which invokes the subcommand fun, but not the help command. Thanks for the help in advance.

Upvotes: 0

Views: 471

Answers (1)

Ratery
Ratery

Reputation: 2917

Check this:

@client.command()
async def invoke_fun(ctx)
    command = client.get_command("help fun")
    ctx.command = command
    ctx.invoked_subcommand = command
    await client.invoke(ctx)

Upvotes: 2

Related Questions