简体   繁体   English

如何在命令中激活命令 (discord.py)

[英]How do I activate a command inside a command (discord.py)

What im trying to do is to make the bot respond when to a command when its under the "help" command list我想做的是让机器人在“帮助”命令列表下响应命令

 @bot.command(pass_context = True)
    async def help(ctx):
        a_embed1 = discord.Embed(title="Vibe's Command List")
        a_embed1.add_field(name=':smile: Fun', value="`vb help fun`", inline=True)
        await ctx.send(embed=a_embed1)

Like when I type " prefix_here help economy", then the economy embed list will be sent rather than the help embed list.就像当我输入“ prefix_here help economy”时,将发送经济嵌入列表而不是帮助嵌入列表。 Any help would be much appreciated!任何帮助将非常感激!

Add an argument and default it to None then check if it's not None then send the common help command else use if-elifs to check what it is equal to and send its help添加一个参数并将其默认为 None 然后检查它是否不是 None 然后发送通用帮助命令否则使用 if-elifs 检查它等于什么并发送它的帮助

@bot.command()
async def help(ctx, c=None):
    if not c: # normal help command
        a_embed1 = discord.Embed(title="Vibe's Command List")
        a_embed1.add_field(name=':smile: Fun', value="`vb help fun`", inline=True)
        await ctx.send(embed=a_embed1)
    elif c.lower() == "economy":
        # define embed and send
    # multiple elifs for other commands

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM