0

如果有人在聊天中说嘿,我希望机器人 dm 他们,但它绝对没有错误,也不起作用

@client.event
async def on_message(message):
  if message.author == client.user:
    return
  if message.content.lower == "hey":
    await message.author.send("heyo")
    await message.add_reaction(":b:")
  await client.process_commands(message)
4

1 回答 1

0

我尝试修改您的代码,但我注意到您没有正确调用较低的函数。lower应该是lower()。这让机器人至少可以给我发消息。

(注意:我还通过使用所需的 write emoji 格式修复了 add_reaction 错误)

@client.event
async def on_message(message):

    if message.author == client.user:
        return

    if message.content.lower() == "hey":
        await message.author.send("heyo")
        await message.add_reaction("️")

    await client.process_commands(message)
于 2021-11-28T15:05:24.207 回答