Skip to content

Commit

Permalink
updated bot.ts & fixed the tracker cron
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Nov 8, 2024
1 parent 9bc1b56 commit 866f3f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/app/cron.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as handler from "@ghom/handler"

import discord from "discord.js"
import cron from "node-cron"
import path from "path"
import url from "url"
import discord from "discord.js"

import * as util from "./util.ts"

Expand Down Expand Up @@ -194,6 +194,9 @@ export function cronKeyToPattern(key: CronIntervalKey): string {
}

export function cronSimpleToPattern(simple: CronIntervalSimple): string {
if (!simple.duration || simple.duration < 0)
throw new CRON_Error("Invalid cron's schedule duration")

switch (simple.type) {
case "minute":
return `*/${simple.duration} * * * *`
Expand Down
8 changes: 3 additions & 5 deletions src/cron/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ export default new app.Cron({
description: "Update the guild tracker every 5 minutes",
schedule: {
type: "minute",
minute: 5,
duration: 5,
},
async run() {
const guilds = await app.client.guilds.fetch()

for (const partialGuild of guilds.values()) {
const guild = await partialGuild.fetch()
const guilds = await app.client.guilds.cache

for (const guild of guilds.values()) {
await app.updateGuildOnlineCountTracker(guild)
await app.updateGuildMessageCountTracker(guild)
}
Expand Down

0 comments on commit 866f3f0

Please sign in to comment.