问题
I have a question with Discord JS How do I remove a specific users reaction from a fetched message? I tried this
message.channel.fetchMessage(messageID).then(m => {
m.reactions.remove(UserID)
})
But it doesn't remove the actual reaction. Help would be appreciated thanks.
回答1:
message.reactions is a collection of messageReactions. I think you need to loop through the collection and then remove the messageReaction required.
message.channel.fetchMessage(messageID).map(r => r).then(message => {
message.reactions.forEach(reaction => reaction.remove(UserID))
})
回答2:
If you look at the documentation for reactions you can see it is a Collection, and it mentions that they are mapped by reaction ID's , and not the user ID's. The way you could remove them is get the reaction, filter the users and then maybe do something with that? I'm not sure how to remove those specifically, but that should get you the users, then filter that to the ID you want.
message.channel.fetchMessage(messageID).then(msg = m.reactions.get(reactionID).users); // Gets the users that reacted to a certain emote, I think.
回答3:
Since this question is getting a lot of attraction, I decided to post what worked for me
Remove Specific User's Specific Reaction
// Channel = the channel object of the message's original channel
// MessageID = ID of the message, if hard coding, put around quotations eg: "1234"
const msg = await channel.fetchMessage(MessageID);
msg.reactions.resolve("REACTION EMOJI,
REACTION OBJECT OR REACTION ID").users.remove("ID OR OBJECT OF USER TO REMOVE");
Note: If using master, simply replace channel.fetchMessage with channel.messages.fetch
来源:https://stackoverflow.com/questions/56379469/remove-a-users-reaction-from-fetchmessage-discord-js