refactor(ThreadManager): Rewrite function

This commit is contained in:
March 7th 2022-06-14 09:05:38 +07:00
parent fbaf3a20e4
commit 131901fd6d

View File

@ -247,13 +247,15 @@ class ThreadManager extends CachedManager {
const raw = this.client.user.bot
? await this.client.api.guilds(this.channel.guild.id).threads.active.get()
: await this.client.api
.channels(this.channel.id)
.threads[
`search?archived=false&limit=${options?.limit || '25'}&offset=${options?.offset || '0'}&sort_by=${
options?.sortBy || 'last_message_time'
}&sort_order=${options?.sortOrder || 'desc'}`
].get();
: await this.client.api.channels(this.channel.id).threads.search.get({
query: {
archived: false,
limit: options?.limit ?? 25,
offset: options?.offset ?? 0,
sort_by: options?.sortBy ?? 'last_message_time',
sort_order: options?.sortOrder ?? 'desc',
},
});
return this.constructor._mapThreads(raw, this.client, { parent: this.channel, cache });
}