首页 > 解决方案 > Discord Bot 命令未发布

问题描述

我编写了一个不和谐机器人,当我使用该命令时,控制台中没有错误,但它没有在频道中发布任何内容。与大多数其他命令一样,该机器人具有正确的权限。

有问题的代码:

@bot.command()
async def plugins(ctx, *args):



    arg = list(map(lambda a: a.upper(), args))
    print(arg)
    if arg == 'LIST':
        embed = discord.Embed()
        embed.set_author(name='Chicken Bot', icon_url=image_url)
        embed.add_field(name='Plugins List', value= '**Server 1**\n Admin Toolbox\n Common Utilities\n PFE\n Chopper Drop\n UAFK\n \n **Server 2**\n Admin Toolbox\n Common Utilities\n PFE\n Chopper Drop\n Ultimate AFK\n Buddy\n SCP Swap\n Tranq Gun\n Stalky 106\n Better 939\n SCP 575\n Better Sinkholes\n \n Do c!plugins (Plugin Name) for more info!')
        await ctx.send(embed = embed)

的结果在控制台中print(arg)['LIST']

帮助表示赞赏!

标签: pythondiscorddiscord.py

解决方案


您正在arg使用此行列出一个列表:

arg = list(map(lambda a: a.upper(), args))

因此['LIST'] != 'LIST',if 语句不会运行。您需要更改您的 if 语句以检查是否arg[0] == 'LIST''LIST' in arg其他内容。但是,您打算运行代码。


推荐阅读