【发布时间】:2019-09-28 20:53:33
【问题描述】:
所以我是整个 discord 机器人场景的新手,我正在尝试从我正在处理的这个机器人将函数返回值打印到不和谐服务器中。
我有这个函数只返回传入的字符串:
def returnParameter(string):
return string
当我尝试将此函数作为命令调用我的不和谐服务器中的机器人时
通过输入例如.bot hello world!,将执行以下代码:
@client.command(aliases = ["bot", "BOT"])
async def botFunction(ctx, *, command):
response = returnParameter(command)
await ctx.send(print(response))
使用上面的例子,我希望我的不和谐服务器打印出"hello world!"
但是我得到了这个错误:
Traceback (most recent call last):
File "/Users/User1/Desktop/Python/venv/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 860, in invoke
await ctx.command.invoke(ctx)
File "/Users/User1/Desktop/Python/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 698, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Users/User1/Desktop/Python/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 72, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: BAD REQUEST (status code: 400): Cannot send an empty message
【问题讨论】:
标签: python http bots discord discord.py