Messages Fetch Fix
Not using endpoint messages, using search endpoint
This commit is contained in:
parent
52e63f117f
commit
91b5be5a88
@ -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) {
|
||||
|
@ -211,6 +211,7 @@ class Message extends Base {
|
||||
* All valid mentions that the message contains
|
||||
* @type {MessageMentions}
|
||||
*/
|
||||
if (!data.mentions)
|
||||
this.mentions = new Mentions(
|
||||
this,
|
||||
data.mentions,
|
||||
@ -219,6 +220,7 @@ class Message extends Base {
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user