Add TextBasedChanel.fetchPinnedMessages()

This commit is contained in:
Amish Shah
2016-08-28 19:42:35 +01:00
parent a57d6b723a
commit 9f1475f358
6 changed files with 38 additions and 1 deletions

View File

@@ -146,6 +146,26 @@ class TextBasedChannel {
return message;
}
/**
* Fetches the pinned messages of this Channel and returns a Collection of them.
* @returns {Promise<Collection<String, Message>, Error>}
*/
fetchPinnedMessages() {
return new Promise((resolve, reject) => {
this.client.rest.methods.getChannelPinnedMessages(this)
.then(data => {
const messages = new Collection();
for (const message of data) {
const msg = new Message(this, message, this.client);
messages.set(message.id, msg);
this._cacheMessage(msg);
}
resolve(messages);
})
.catch(reject);
});
}
}
function applyProp(structure, prop) {
@@ -159,6 +179,7 @@ exports.applyToClass = (structure, full = false) => {
props.push('getMessages');
props.push('bulkDelete');
props.push('setTyping');
props.push('fetchPinnedMessages');
}
for (const prop of props) {
applyProp(structure, prop);