diff --git a/src/managers/MessageManager.js b/src/managers/MessageManager.js index a1e9a8b..27538dc 100644 --- a/src/managers/MessageManager.js +++ b/src/managers/MessageManager.js @@ -2,10 +2,11 @@ const { Collection } = require('@discordjs/collection'); const CachedManager = require('./CachedManager'); -const { TypeError } = require('../errors'); +const { TypeError, Error } = require('../errors'); const { Message } = require('../structures/Message'); const MessagePayload = require('../structures/MessagePayload'); const Util = require('../util/Util'); +const BigNumber = require('bignumber.js'); /** * Manages API methods for Messages and holds their cache. @@ -216,8 +217,19 @@ class MessageManager extends CachedManager { if (existing && !existing.partial) return existing; } - const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); - return this._add(data, cache); + // const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); // Discord Block + // https://canary.discord.com/api/v9/guilds/809133733591384155/messages/search?channel_id=840225732902518825&max_id=957254525360697375&min_id=957254525360697373 + const data = ( + await this.client.api.guilds[this.channel.guild.id].messages.search.get({ + query: { + channel_id: this.channel.id, + max_id: new BigNumber.BigNumber(messageId).plus(1).toString(), + min_id: new BigNumber.BigNumber(messageId).minus(1).toString(), + }, + }) + ).messages[0] + if (data) return this._add(data[0], cache); + else throw new Error('MESSAGE_ID_NOT_FOUND'); } async _fetchMany(options = {}, cache) { diff --git a/src/structures/Message.js b/src/structures/Message.js index d02f3fc..918edf5 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -211,14 +211,16 @@ class Message extends Base { * All valid mentions that the message contains * @type {MessageMentions} */ - this.mentions = new Mentions( - this, - data.mentions, - data.mention_roles, - data.mention_everyone, - data.mention_channels, - data.referenced_message?.author, - ); + if (!data.mentions) + this.mentions = new Mentions( + this, + data.mentions, + data.mention_roles, + data.mention_everyone, + data.mention_channels, + data.referenced_message?.author, + ); + else data.mentions instanceof Mentions ? this.mentions = data.mentions : this.mentions = null; } else { this.mentions = new Mentions( this,