From cd49809ff13eb99c01acddebe60dce2cb2f030b9 Mon Sep 17 00:00:00 2001 From: SocksOnHead Date: Thu, 19 Oct 2023 01:22:00 +0200 Subject: [PATCH] Fixed timer issue --- bot.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.ts b/bot.ts index 4adfe2a..25da71e 100644 --- a/bot.ts +++ b/bot.ts @@ -156,13 +156,13 @@ function getRandomSoundFilePath(): string { * Schedules the next join to a random channel. Using a random interval between minTime and maxTime. * It clears the previous schedule before scheduling the next join, to avoid multiple schedules. * @see minTimeInterval - time in minutes - * @see maxTimeInterval - time in hours + * @see maxTimeInterval - time in hours as minutes * @see schedule - node-schedule instance */ function scheduleNextJoin(): void { const randomInterval = Math.floor(Math.random() * (maxTimeInterval - minTimeInterval + 1)) + minTimeInterval; const minutes = randomInterval % 60; - const hours = Math.floor(randomInterval / 60); + const hours = Math.floor((randomInterval - minutes) / 60); schedule.gracefulShutdown().finally(() => { const jobName = schedule.scheduleJob(`${Math.floor(minutes)} ${Math.floor(hours) == 0 ? '*' : Math.floor(hours) } * * *`, function(){ @@ -204,4 +204,4 @@ function log( function dateToString(date: Date): string { return date.toLocaleString('sv-SE', { timeZone: 'Europe/Stockholm' }); -} \ No newline at end of file +}