mirror of
https://github.com/danbulant/discord.js
synced 2026-06-18 22:21:17 +00:00
Add TextBasedChanel.fetchPinnedMessages()
This commit is contained in:
parent
a57d6b723a
commit
9f1475f358
6 changed files with 38 additions and 1 deletions
File diff suppressed because one or more lines are too long
|
|
@ -492,6 +492,10 @@ class RESTMethods {
|
|||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
getChannelPinnedMessages(channel) {
|
||||
return this.rest.makeRequest('get', `${Constants.Endpoints.channel(channel.id)}/pins`, true);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ class DMChannel extends Channel {
|
|||
setTyping() {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchPinnedMessages() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TextBasedChannel.applyToClass(DMChannel, true);
|
||||
|
|
|
|||
|
|
@ -139,6 +139,10 @@ class GroupDMChannel extends Channel {
|
|||
setTyping() {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchPinnedMessages() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TextBasedChannel.applyToClass(GroupDMChannel, true);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ class TextChannel extends GuildChannel {
|
|||
setTyping() {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchPinnedMessages() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TextBasedChannel.applyToClass(TextChannel, true);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue