Python on_reaction_add仅在bot最初将反应添加到消息时调用
我有一些密码Python on_reaction_add仅在bot最初将反应添加到消息时调用,python,discord.py,Python,Discord.py,我有一些密码 @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", br
@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修复了此问题。on_reaction_add()
要求消息位于内部消息缓存中。请尝试使用此选项:
on_raw_reaction_add(有效载荷)
查看更多信息。邮件是否已缓存?谢谢,我尝试过,效果非常好!