使用“wait_for” discord.py 在等待反应时出错

时间:2021-03-23 12:30:14

标签: python async-await attributes tuples discord.py

在等待对机器人之前发送给用户 dms 的消息做出反应时出现此错误

reaction = await client.wait_for("reaction_add")
if str(reaction.emoji) == "1️⃣":
  await player.user.send("you have selected %s lol"%(members[0]))

Error:

'tuple' object has no attribute 'emoji'

1 个答案:

答案 0 :(得分:1)

等待响应时,wait_for 方法返回两个值 - discord.Reactiondiscord.User 实例。要修复您的代码:

reaction, user = await client.wait_for("reaction_add")