Search code examples
pythondiscorddiscord.py

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.


Solution

  • 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)