From 131901fd6dc318724d757f2bb9138132ce84ff7c Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Tue, 14 Jun 2022 09:05:38 +0700 Subject: [PATCH] refactor(ThreadManager): Rewrite function --- src/managers/ThreadManager.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/managers/ThreadManager.js b/src/managers/ThreadManager.js index f143a7f..cb6b837 100644 --- a/src/managers/ThreadManager.js +++ b/src/managers/ThreadManager.js @@ -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 }); }