AttributeError: 'str' object has no attribute 'send'

AttributeError: 'str' object has no attribute 'send'

所以我正在尝试让我的 on_message 活动在不阻止命令的情况下运行。我添加了 await client.process_commands(message) 行,但现在它告诉我 'str' 对象没有属性 'send',我不知道这是什么意思。这是我正在处理的代码。

@client.event
async def on_message(message):
    if message.content.lower().startswith("hi"):
        await message.content.send('hello brotha')
    await client.process_commands(message)

有解决办法吗??

message.content 是类型 str。您在其上调用 .send('hello brotha'),从而导致该错误消息。如果您要回复初始消息,您应该这样做:

@client.event
async def on_message(message):
    if message.content.lower().startswith("hi"):
        await message.reply('hello brotha')
    await client.process_commands(message)

您应该参考 discord.py 文档。