机器人发送消息信息而不是消息



所以我目前正在制作一个聊天频道,在那里你可以在频道中聊天,机器人程序会将其发送到另一个服务器,该服务器的频道名为chat-chan

这是我的代码:

async def on_message(message):
    if message.channel.name == 'chat-chan' and message.author.bot == False:
        await message.channel.send(f"{message.author.name}:  {message}")

相反,它发送消息的信息,而不是消息本身

迷你版:<消息id=12345678910 channel=type=<消息类型默认值:0>author=<会员id=12345678910 name='Mini'鉴别器='4140'bot=False nick=None guild=>flags=>

您正在发送消息的对象。要访问消息本身,您需要将其替换为message.content

async def on_message(message):
    if message.channel.name == 'chat-chan' and message.author.bot == False:
        await message.channel.send(f"{message.author.name}:  {message.content}")

最新更新