Skip to content

Commit

Permalink
updated tracker cron & bot.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Nov 8, 2024
1 parent 7288000 commit 9bc1b56
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/cron/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
17 changes: 15 additions & 2 deletions src/listeners/cron.ready.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
},
})

0 comments on commit 9bc1b56

Please sign in to comment.