remove users from message reactions

This commit is contained in:
Amish Shah
2016-10-27 17:16:40 +01:00
parent dd9c291508
commit 9cba1bc6d0
3 changed files with 18 additions and 6 deletions

View File

@@ -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,

View File

@@ -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);
}
/**

View File

@@ -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}` : ''}`,