parent
c794e9ac6b
commit
47104f8118
@ -220,20 +220,31 @@ class MessageManager extends CachedManager {
|
|||||||
if (existing && !existing.partial) return existing;
|
if (existing && !existing.partial) return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); // Discord Block
|
if (this.channel.guildId) {
|
||||||
// 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.guilds[this.channel.guild.id].messages.search.get({
|
query: {
|
||||||
query: {
|
channel_id: this.channel.id,
|
||||||
channel_id: this.channel.id,
|
max_id: new BigNumber.BigNumber(messageId).plus(1).toString(),
|
||||||
max_id: new BigNumber.BigNumber(messageId).plus(1).toString(),
|
min_id: new BigNumber.BigNumber(messageId).minus(1).toString(),
|
||||||
min_id: new BigNumber.BigNumber(messageId).minus(1).toString(),
|
include_nsfw: true,
|
||||||
include_nsfw: true,
|
},
|
||||||
},
|
})
|
||||||
})
|
).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');
|
} else {
|
||||||
|
const data = (
|
||||||
|
await this.client.api.channels[this.channel.id].messages.search.get({
|
||||||
|
query: {
|
||||||
|
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) {
|
async _fetchMany(options = {}, cache) {
|
||||||
@ -286,7 +297,7 @@ class MessageManager extends CachedManager {
|
|||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
const stringQuery = [];
|
let stringQuery = [];
|
||||||
const result = new Collection();
|
const result = new Collection();
|
||||||
let data;
|
let data;
|
||||||
if (author.length > 0) stringQuery.push(author.map(id => `author_id=${id}`).join('&'));
|
if (author.length > 0) stringQuery.push(author.map(id => `author_id=${id}`).join('&'));
|
||||||
@ -313,6 +324,7 @@ class MessageManager extends CachedManager {
|
|||||||
if (this.channel.guildId) {
|
if (this.channel.guildId) {
|
||||||
data = await this.client.api.guilds[this.channel.guildId].messages[`search?${stringQuery.join('&')}`].get();
|
data = await this.client.api.guilds[this.channel.guildId].messages[`search?${stringQuery.join('&')}`].get();
|
||||||
} else {
|
} else {
|
||||||
|
stringQuery = stringQuery.filter(v => !v.startsWith('channel_id') && !v.startsWith('include_nsfw'));
|
||||||
data = await this.client.api.channels[this.channel.id].messages[`search?${stringQuery.join('&')}`].get();
|
data = await this.client.api.channels[this.channel.id].messages[`search?${stringQuery.join('&')}`].get();
|
||||||
}
|
}
|
||||||
for await (const message of data.messages) result.set(message[0].id, new Message(this.client, message[0]));
|
for await (const message of data.messages) result.set(message[0].id, new Message(this.client, message[0]));
|
||||||
|
Loading…
Reference in New Issue
Block a user