mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
Expose TextBasedChannel#fetchMessage() (#602)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -287,6 +287,18 @@ class RESTMethods {
|
||||
});
|
||||
}
|
||||
|
||||
getChannelMessage(channel, messageID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const msg = channel.messages.get(messageID);
|
||||
if (msg) return resolve(msg);
|
||||
|
||||
const endpoint = Constants.Endpoints.channelMessage(channel.id, messageID);
|
||||
return this.rest.makeRequest('get', endpoint, true)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
updateGuildMember(member, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (data.channel) data.channel_id = this.rest.client.resolver.resolveChannel(data.channel).id;
|
||||
|
||||
@@ -59,6 +59,10 @@ class DMChannel extends Channel {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchMessage() {
|
||||
return;
|
||||
}
|
||||
|
||||
bulkDelete() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ class GroupDMChannel extends Channel {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchMessage() {
|
||||
return;
|
||||
}
|
||||
|
||||
bulkDelete() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ class TextChannel extends GuildChannel {
|
||||
return;
|
||||
}
|
||||
|
||||
fetchMessage() {
|
||||
return;
|
||||
}
|
||||
|
||||
bulkDelete() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,28 @@ class TextBasedChannel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single message from this channel, regardless of it being cached or not.
|
||||
* @param {string} messageID The ID of the message to get
|
||||
* @returns {Promise<Message>}
|
||||
* @example
|
||||
* // get message
|
||||
* channel.fetchMessage('99539446449315840')
|
||||
* .then(message => console.log(message.content))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchMessage(messageID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.rest.methods.getChannelMessage(this, messageID).then(data => {
|
||||
let msg = data;
|
||||
if (!(msg instanceof Message)) msg = new Message(this, data, this.client);
|
||||
|
||||
this._cacheMessage(msg);
|
||||
resolve(msg);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a typing indicator in the channel.
|
||||
* @param {number} [count] The number of times startTyping should be considered to have been called
|
||||
@@ -394,6 +416,7 @@ exports.applyToClass = (structure, full = false) => {
|
||||
if (full) {
|
||||
props.push('_cacheMessage');
|
||||
props.push('fetchMessages');
|
||||
props.push('fetchMessage');
|
||||
props.push('bulkDelete');
|
||||
props.push('startTyping');
|
||||
props.push('stopTyping');
|
||||
|
||||
Reference in New Issue
Block a user