python - 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']
帮助表示赞赏!
解决方案
您正在arg
使用此行列出一个列表:
arg = list(map(lambda a: a.upper(), args))
因此['LIST'] != 'LIST'
,if 语句不会运行。您需要更改您的 if 语句以检查是否arg[0] == 'LIST'
或'LIST' in arg
其他内容。但是,您打算运行代码。
推荐阅读
- ios - 如何更改 MGLPolyline 的颜色?
- c++ - 无法在 C++ 中删除动态数组的内容
- c# - 尝试聚焦 xamarin.forms 中的条目时,字段初始值设定项无法引用非静态字段、方法或属性错误
- c++ -
如何在“(”令牌双向链表::Node::Node(data)之前修复“预期的构造函数、析构函数或类型转换” - java - 从android发送时令牌显示已过期
- bluetooth-lowenergy - 网状消息操作码
- php - 获取未定义索引:在 CodeIgniter 中注销后的 login_session
- powershell - 如何在powershell中执行命令“pip install”并与数组元素连接
- java - 无法迭代包含链接哈希图的数组列表
- react-native - 触摸事件不适用于反应导航