【发布时间】:2021-02-14 06:39:37
【问题描述】:
我正在尝试创建一个 eval 命令,例如:用户键入“!eval print('foo')”,然后机器人将在此发送给定代码的输出案例:“foo” 这是我的代码:
async def eval(args):
res = eval(' '.join(args))
await send(await res)
它给了我这个错误:
File ".py", line 47, in eval
await message.channel.send(await res)
TypeError: object NoneType can't be used in 'await' expression
有人可以帮忙吗?
【问题讨论】:
-
res是否包含任何内容? -
是的,确实如此,“args”参数是命令名称在每个空格处拆分后出现的所有内容,所以这里应该是“[print('foo')]”,但我测试过查看,当我打印 res 时,它会打印 None
-
另外,通过声明 res 变量,我在输出中看到“foo”。
标签: python discord discord.py discord.py-rewrite