Fixed timer issue

This commit is contained in:
2023-10-19 01:22:00 +02:00
committed by GitHub
parent d1bffddd46
commit cd49809ff1

4
bot.ts
View File

@@ -156,13 +156,13 @@ function getRandomSoundFilePath(): string {
* Schedules the next join to a random channel. Using a random interval between minTime and maxTime. * 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. * It clears the previous schedule before scheduling the next join, to avoid multiple schedules.
* @see minTimeInterval - time in minutes * @see minTimeInterval - time in minutes
* @see maxTimeInterval - time in hours * @see maxTimeInterval - time in hours as minutes
* @see schedule - node-schedule instance * @see schedule - node-schedule instance
*/ */
function scheduleNextJoin(): void { function scheduleNextJoin(): void {
const randomInterval = Math.floor(Math.random() * (maxTimeInterval - minTimeInterval + 1)) + minTimeInterval; const randomInterval = Math.floor(Math.random() * (maxTimeInterval - minTimeInterval + 1)) + minTimeInterval;
const minutes = randomInterval % 60; const minutes = randomInterval % 60;
const hours = Math.floor(randomInterval / 60); const hours = Math.floor((randomInterval - minutes) / 60);
schedule.gracefulShutdown().finally(() => { schedule.gracefulShutdown().finally(() => {
const jobName = schedule.scheduleJob(`${Math.floor(minutes)} ${Math.floor(hours) == 0 ? '*' : Math.floor(hours) } * * *`, function(){ const jobName = schedule.scheduleJob(`${Math.floor(minutes)} ${Math.floor(hours) == 0 ? '*' : Math.floor(hours) } * * *`, function(){