Webpack build for branch master: 64ce829ab2

This commit is contained in:
Travis CI 2017-03-21 05:44:19 +00:00
parent 0f59dde4e0
commit 944f5f0852
2 changed files with 10 additions and 2 deletions

View file

@ -3751,7 +3751,8 @@ class TextBasedChannel {
/**
* Gets a single message from this channel, regardless of it being cached or not.
* <warn>This is only available when using a bot account.</warn>
* Since the single message fetching endpoint is reserved for bot accounts, this abstracts
* {@link #fetchMessages} to obtain the single message when using a user account.
* @param {Snowflake} messageID ID of the message to get
* @returns {Promise<Message>}
* @example
@ -3761,6 +3762,13 @@ class TextBasedChannel {
* .catch(console.error);
*/
fetchMessage(messageID) {
if (!this.client.user.bot) {
return this.fetchMessages({ limit: 1, around: messageID }).then(messages => {
const msg = messages.first();
if (msg.id !== messageID) throw new Error('Message not found.');
return msg;
});
}
return this.client.rest.methods.getChannelMessage(this, messageID).then(data => {
const msg = data instanceof Message ? data : new Message(this, data, this.client);
this._cacheMessage(msg);

File diff suppressed because one or more lines are too long