我有一些代码
@bot.event
async def on_reaction_add(reaction, user):
print("hello")
if(user.id == bot.user.id):
return
if(not reaction.message.guild):
await reaction.message.delete()
@bot.command(name="dm", brief="Anonymously dms user")
async def dm(ctx, user: discord.Member, *, message=None):
await ctx.message.delete()
if(message is None):
await ctx.send("Enter a message to send to this user!")
return
msg = await user.send("**An anonymous user sent you this:** "+message)
await msg.add_reaction("\U0001F5D1")
on_reaction_add 仅在我的机器人最初对其自己的消息添加反应时才被调用。当我尝试向消息添加反应时,hello 不会打印到终端中,也没有任何错误。
编辑:通过使用 on_raw_reaction_add 而不是 on_reaction_add 修复了问题。
答案 0 :(得分:1)