【问题标题】:Discord.py bot doesn't dm userDiscord.py bot 没有 dm 用户
【发布时间】:2022-01-05 16:54:19
【问题描述】:

如果有人在聊天中说嘿,我希望机器人 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)

【问题讨论】:

  • 您是否设置了不和谐意图?
  • 是的,虽然在较低的函数之后我错过了括号

标签: discord discord.py bots dm


【解决方案1】:

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

(注意:我还通过使用所需的写入表情符号格式修复了 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)

【讨论】:

  • 非常感谢,我完全错过了括号
猜你喜欢
  • 2019-08-22
  • 2022-01-09
  • 2021-04-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-27
  • 2021-12-03
  • 2020-11-13
  • 2021-12-24
相关资源
最近更新 更多