mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Throwing 'Message not found' error when fetching from empty channel or without read history permission. (#1394)
This commit is contained in:
@@ -129,8 +129,8 @@ class TextBasedChannel {
|
|||||||
fetchMessage(messageID) {
|
fetchMessage(messageID) {
|
||||||
if (!this.client.user.bot) {
|
if (!this.client.user.bot) {
|
||||||
return this.fetchMessages({ limit: 1, around: messageID }).then(messages => {
|
return this.fetchMessages({ limit: 1, around: messageID }).then(messages => {
|
||||||
const msg = messages.first();
|
const msg = messages.get(messageID);
|
||||||
if (msg.id !== messageID) throw new Error('Message not found.');
|
if (!msg) throw new Error('Message not found.');
|
||||||
return msg;
|
return msg;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user