【问题标题】:discord.py invoke subcommanddiscord.py 调用子命令
【发布时间】:2022-01-07 12:51:26
【问题描述】:

基本上我想调用一个子命令。如果我在这里有这段代码,有趣的是子命令:

@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")

我想要另一个命令,例如: async def invoke_fun(ctx),它调用子命令 fun,但不调用 help 命令。 提前感谢您的帮助。

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    检查一下:

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

    【讨论】:

    • 啊,太感谢了!
    猜你喜欢
    • 2020-07-15
    • 2021-07-24
    • 2021-03-26
    • 2020-08-02
    • 2021-08-28
    • 2021-01-22
    • 2021-03-30
    • 2021-05-17
    • 2021-01-15
    相关资源
    最近更新 更多