From 9bc1b56e8db4d258b88f0044f7d57d701357f9fd Mon Sep 17 00:00:00 2001 From: GhomKrosmonaute Date: Fri, 8 Nov 2024 13:55:42 +0100 Subject: [PATCH] updated tracker cron & bot.ts --- src/cron/tracker.ts | 6 +++++- src/listeners/cron.ready.native.ts | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cron/tracker.ts b/src/cron/tracker.ts index 9f44fc0..78d9023 100644 --- a/src/cron/tracker.ts +++ b/src/cron/tracker.ts @@ -11,7 +11,11 @@ export default new app.Cron({ minute: 5, }, async run() { - for (const guild of app.client.guilds.cache.values()) { + const guilds = await app.client.guilds.fetch() + + for (const partialGuild of guilds.values()) { + const guild = await partialGuild.fetch() + await app.updateGuildOnlineCountTracker(guild) await app.updateGuildMessageCountTracker(guild) } diff --git a/src/listeners/cron.ready.native.ts b/src/listeners/cron.ready.native.ts index 0330bda..af94201 100644 --- a/src/listeners/cron.ready.native.ts +++ b/src/listeners/cron.ready.native.ts @@ -10,10 +10,23 @@ export default new app.Listener({ event: "ready", description: "Launch all cron jobs", async run() { + let launched = 0 + for (const cron of app.cronList.values()) { - cron.start() + try { + cron.start() + launched++ + } catch (error) { + if (typeof error === "string" || error instanceof Error) + logger.error(error, cron.filepath, true) + else + logger.error( + "an error occurred while starting the cron job", + cron.filepath, + ) + } } - logger.success("All cron jobs launched") + logger.success(`launched ${launched} cron jobs`) }, })