我正在使用 async def on_raw_reaction_remove(payload)
来跟踪用户何时删除反应.如何获取触发事件的用户?在我的代码中,我让我的机器人通过在某些情况下删除反应来触发此事件 - 但是当这种情况发生时 user = await client.fetch_user(user_id)
总是等于对删除的反应做出反应的用户并且不是删除它的机器人(当机器人删除某人的反应时,我需要让机器人成为用户,所以我可以说 if user == bot: return我也试过了
I am using async def on_raw_reaction_remove(payload)
to track when a user removes a reaction..
How do I get the user who triggered the event? In my code i have my bot trigger this event by removing reactions in certain scenarios - but when this happens user = await client.fetch_user(user_id)
always equals to the user who had reacted with the removed reaction and not the bot that removed it (i need to get the bot as user when the bot removes someone's reaction, so i can say if user == bot: return
I also tried
message = await channel.fetch_message(payload.message_id)
guild = message.guild
member = await guild.fetch_member(payload.user_id)
但它是相同的.. 成员始终指向已删除反应的所有者,而不是删除反应的机器人...使用 on_raw_reaction_remove 时,我怎样才能得到消除反应的人?
but it's the same.. the member is always pointing to the owner of the reaction that was removed, not the bot that's removing the reaction... How can i get the one who is removing the reaction when using on_raw_reaction_remove?
(如果相关 - 我在 discord 的开发者门户中启用了意图并更新了我的代码
(if it's relevant - i enabled intents in discord's developer portal and updated my code with
intents = discord.Intents.all()
client = discord.Client(intents=intents)
感谢您的帮助,我已经在这方面浪费了很多时间:皱眉:(不和谐 api 的新手)
Thanks for your help, i wasted so much time on this already :frowning: (new to the discord api)
答案是——discord python API 中没有任何东西可以告诉你是谁删除了反应.
The answer is - there is nothing in the discord python API that can tell you who removed the reaction.
对于我的情况,我通过一种解决方法解决了这个问题 - 我只需要跟踪我的机器人是否删除了一个带有变量的反应 - 我正在使用一个全局变量来跟踪我的机器人何时删除了一个反应,然后稍后再检查是否变量是 True
或 False
并做出相应的响应并重新设置变量.
For my case, I solved it with a workaround - I just had to track if my bot removed a reaction with a variable - I am using a global variable to track when my bot removes a reaction and then just check later if the variable is True
or False
and respond accordingly and reset the variable back.
谢谢
这篇关于获取触发 on_raw_reaction_remove(payload) 的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!