简体   繁体   English

您如何让 Discord 机器人删除用户对 discord.py 中的消息的反应?

[英]How do you have a Discord bot remove a user reaction to a message in discord.py?

I'm using an @client.event and using async def on_raw_reaction_add(payload): to read Discord reaction events.我正在使用@client.event并使用async def on_raw_reaction_add(payload):来读取 Discord 反应事件。 I need to be able to delete a user reaction when they fail one of the flags in my code.当我的代码中的标志之一失败时,我需要能够删除用户反应。 I saw in the documentation that there is await remove(user) but I don't think I'm using it right.我在文档中看到有await remove(user)但我认为我没有正确使用它。 Any suggestions?有什么建议么?

You can use either Message.remove_reaction or Reaction.remove .您可以使用Message.remove_reactionReaction.remove

A Reaction object represents a specific emoji reaction to a Message , so if the Reaction object you have is not for the emoji reaction that you want to remove, using Reaction.remove will attempt to remove the wrong emoji reaction.Reaction对象表示对Message的特定表情符号反应,因此如果您拥有的 Reaction 对象不是要删除的表情符号反应,则使用Reaction.remove将尝试删除错误的表情符号反应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM