繁体   English   中英

如何删除 Discord.js 中特定用户对消息的反应?

[英]How do I remove a reaction from a message by a specific user in Discord.js?

我想删除特定用户对我获取的消息的反应。 但是我无法让它工作(可能是因为我是一个不会做 Javascript 的 weeb),所以如果我能得到一些帮助会很好:)

我试着环顾四周,例如 [this] Remove a users react from fetchMessage? - Discord JS线程,但是它返回为 map 未定义。

我最近想出的是这样的:

            var messageEmbed = message.channel.fetchMessage('637189841418846208')
                .catch(console.error);
                messageEmbed.reactions.remove(message.author.id)

我希望它消除反应,但我收到错误“UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'remove' of undefined”

“反应”是反应的集合,因此您需要首先找到您要查找的特定反应,此示例获取消息的第一个反应并尝试从反应中删除用户。

let messageEmbed = message.channel.fetchMessage('637189841418846208')
.catch(console.error);
messageEmbed.reactions.first().remove(message.author.id)

还有许多其他方法可以在集合中搜索特定反应,一般一种是 .get() 方法,在这种情况下,它将根据反应的 ID 搜索反应

messageEmbed.reactions.get("REACTION ID")

要查看所有可用的方法,请参阅CollectionReaction

暂无
暂无

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

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