fix: remove get query loop loop de loop loop

This commit is contained in:
Skillz4Killz
2022-03-26 00:11:47 +00:00
committed by GitHub
parent 80d2e94840
commit b06f6d2512
15 changed files with 126 additions and 81 deletions
+14 -12
View File
@@ -10,21 +10,23 @@ export async function getArchivedThreads(
type?: "public" | "private" | "privateJoinedThreads";
},
) {
let url = options?.type === "privateJoinedThreads"
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE_JOINED(channelId)
: options?.type === "private"
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
: bot.constants.endpoints.THREAD_ARCHIVED_PUBLIC(channelId);
if (options) {
url += "?";
if (options.before) url += `before=${options.before}`;
if (options.limit) url += `&limit=${options.limit}`;
if (options.type) url += `&type=${options.type}`;
}
const result = (await bot.rest.runMethod<DiscordListActiveThreads>(
bot.rest,
"get",
options?.type === "privateJoinedThreads"
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE_JOINED(channelId)
: options?.type === "private"
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
: bot.constants.endpoints.THREAD_ARCHIVED_PUBLIC(channelId),
options
? {
before: options.before,
limit: options.limit,
type: options.type,
}
: {},
url,
));
return {