From a4b411348120a7bdcc857b99b6ea7b762b761466 Mon Sep 17 00:00:00 2001 From: Krayon <62216007+Krayon0@users.noreply.github.com> Date: Sat, 13 Aug 2022 17:45:07 +0300 Subject: [PATCH] Update index.ts --- src/index.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index f0c448d..feaa13e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -73,7 +73,7 @@ export async function createTranscript< channel: ValidTextChannels, opts?: T ): Promise> { - var options: CreateTranscriptOptions = optsSetup(opts, channel); + const options: CreateTranscriptOptions = optsSetup(opts, channel); if (!('limit' in options)) options.limit = -1; if (!channel) @@ -95,18 +95,14 @@ export async function createTranscript< var last_id: string | undefined; while (true) { - const options = { limit: 100, before: last_id }; - if (!last_id) delete options['before']; + var fetchOptions = { limit: 100, before: last_id }; + if (!last_id) delete fetchOptions['before']; - const messages = await channel.messages.fetch(options); + const messages = await channel.messages.fetch(fetchOptions); sum_messages.push(...Array.from(messages.values())); last_id = messages.last()?.id; - if ( - messages.size != 100 || - (options.limit! > 0 && sum_messages.length >= options.limit!) - ) - break; + if (messages.size != 100 || (sum_messages.length >= options.limit! && options.limit! != -1)) break; } return await exportHtml(sum_messages, channel, options) as any;