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 const raw = this.client.user.bot
? await this.client.api.guilds(this.channel.guild.id).threads.active.get() ? await this.client.api.guilds(this.channel.guild.id).threads.active.get()
: await this.client.api : await this.client.api.channels(this.channel.id).threads.search.get({
.channels(this.channel.id) query: {
.threads[ archived: false,
`search?archived=false&limit=${options?.limit || '25'}&offset=${options?.offset || '0'}&sort_by=${ limit: options?.limit ?? 25,
options?.sortBy || 'last_message_time' offset: options?.offset ?? 0,
}&sort_order=${options?.sortOrder || 'desc'}` sort_by: options?.sortBy ?? 'last_message_time',
].get(); sort_order: options?.sortOrder ?? 'desc',
},
});
return this.constructor._mapThreads(raw, this.client, { parent: this.channel, cache }); return this.constructor._mapThreads(raw, this.client, { parent: this.channel, cache });
} }