mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
remove users from message reactions
This commit is contained in:
@@ -737,12 +737,16 @@ class RESTMethods {
|
||||
});
|
||||
}
|
||||
|
||||
removeMessageReaction(channelID, messageID, emoji) {
|
||||
removeMessageReaction(channelID, messageID, emoji, userID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest('delete', Constants.Endpoints.selfMessageReaction(channelID, messageID, emoji), true)
|
||||
let endpoint = Constants.Endpoints.selfMessageReaction(channelID, messageID, emoji);
|
||||
if (userID !== this.rest.client.user.id) {
|
||||
endpoint = Constants.Endpoints.userMessageReaction(channelID, messageID, emoji, null, userID);
|
||||
}
|
||||
this.rest.makeRequest('delete', endpoint, true)
|
||||
.then(() => {
|
||||
resolve(this.rest.client.actions.MessageReactionRemove.handle({
|
||||
user_id: this.rest.client.user.id,
|
||||
user_id: userID,
|
||||
message_id: messageID,
|
||||
emoji: parseEmoji(emoji),
|
||||
channel_id: channelID,
|
||||
|
||||
@@ -101,12 +101,18 @@ class MessageReaction {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the client has given this reaction to a message, it is removed.
|
||||
* Removes a user from this reaction.
|
||||
* @param {UserResolvable} [user] the user that you want to remove the reaction, defaults to the client.
|
||||
* @returns {Promise<MessageReaction>}
|
||||
*/
|
||||
remove() {
|
||||
remove(user = this.message.client.user) {
|
||||
const message = this.message;
|
||||
return message.client.rest.methods.removeMessageReaction(message.channel.id, message.id, this.emoji.identifier);
|
||||
user = this.message.client.resolver.resolveUserID(user);
|
||||
|
||||
if (!user) return Promise.reject('A UserIDResolvable is required (string, user, member, message, guild)');
|
||||
|
||||
return message.client.rest.methods.removeMessageReaction(
|
||||
message.channel.id, message.id, this.emoji.identifier, user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,6 +123,8 @@ const Endpoints = exports.Endpoints = {
|
||||
`${limit ? `?limit=${limit}` : ''}`,
|
||||
selfMessageReaction: (channel, msg, emoji, limit) =>
|
||||
`${Endpoints.messageReaction(channel, msg, emoji, limit)}/@me`,
|
||||
userMessageReaction: (channel, msg, emoji, limit, id) =>
|
||||
`${Endpoints.messageReaction(channel, msg, emoji, limit)}/${id}`,
|
||||
|
||||
// webhooks
|
||||
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,
|
||||
|
||||
Reference in New Issue
Block a user