Merge pull request #204 from websharik/main

fix(MessageManager): fetch throw 'Missing Access'
This commit is contained in:
Cinnamon 2022-07-14 23:32:15 +07:00 committed by GitHub
commit 40db78ea7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,13 +223,7 @@ class MessageManager extends CachedManager {
// Const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); // Discord Block // 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 // https://canary.discord.com/api/v9/guilds/809133733591384155/messages/search?channel_id=840225732902518825&max_id=957254525360697375&min_id=957254525360697373
const data = ( const data = (
await this.client.api.guilds[this.channel.guild.id].messages.search.get({ await this.client.api.channels[this.channel.id].messages.get({ query: { limit: 1, around: messageId }})
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]; ).messages[0];
if (data) return this._add(data[0], cache); if (data) return this._add(data[0], cache);
else throw new Error('MESSAGE_ID_NOT_FOUND'); else throw new Error('MESSAGE_ID_NOT_FOUND');