我如何让我的 Python Discord 机器人模仿所有发送的消息?

How would I make my Python Discord bot mimic all messages sent?

我正在使用 Python (v. 3.6.1) 编写一个 Discord 机器人。它的功能之一是检测通道中发送的所有消息,处理它们,然后响应所述通道中的消息。 (至少,这是我想要它做的。)

我试过这个:

@bot.event
async def on_message(message):
    await bot.say(message.content)

该函数在发送消息时做出响应,但不是以我希望的方式响应。相反,我得到一个错误:

discord.errors.InvalidArgument: Destination must be Channel, PrivateChannel, User, or Object. Received NoneType

我该如何解决这个问题?非常感谢!

您不能在命令外使用 bot.say

Can I use bot.say in other places aside from commands?

No. They only work inside commands due to the way the magic involved works.

http://discordpy.readthedocs.io/en/latest/faq.html#can-i-use-bot-say-in-other-places-aside-from-commands

要让机器人重复发送的每条消息,您可以使用 send_message。下面是一个例子。

@client.event
async def on_message(message):
    await client.send_message(message.channel, message.content)