mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Add TextBasedChanel.fetchPinnedMessages()
This commit is contained in:
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);
|
||||
|
||||
Reference in New Issue
Block a user