Start work on adding reaction support

This commit is contained in:
Amish Shah
2016-10-27 15:22:42 +01:00
parent dd31ee0c5f
commit 81059885a2
12 changed files with 252 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
const Constants = require('../../util/Constants');
const Collection = require('../../util/Collection');
const splitMessage = require('../../util/SplitMessage');
const parseEmoji = require('../../util/ParseEmoji');
const requireStructure = name => require(`../../structures/${name}`);
const User = requireStructure('User');
@@ -720,6 +721,36 @@ class RESTMethods {
.catch(reject);
});
}
addMessageReaction(channelID, messageID, emoji) {
return new Promise((resolve, reject) => {
this.rest.makeRequest('put', Constants.Endpoints.selfMessageReaction(channelID, messageID, emoji), true)
.then(() => {
resolve(this.rest.client.actions.MessageReactionAdd.handle({
user_id: this.rest.client.user.id,
message_id: messageID,
emoji: parseEmoji(emoji),
channel_id: channelID,
}).reaction);
})
.catch(reject);
});
}
removeMessageReaction(channelID, messageID, emoji) {
return new Promise((resolve, reject) => {
this.rest.makeRequest('delete', Constants.Endpoints.selfMessageReaction(channelID, messageID, emoji), true)
.then(() => {
resolve(this.rest.client.actions.MessageReactionRemove.handle({
user_id: this.rest.client.user.id,
message_id: messageID,
emoji: parseEmoji(emoji),
channel_id: channelID,
}).reaction);
})
.catch(reject);
});
}
}
module.exports = RESTMethods;