Updated dir structure

This commit is contained in:
2024-01-15 11:00:11 +01:00
parent 06ab42e258
commit 301ab66f58
26 changed files with 62 additions and 80 deletions

37
src/utils/Events/cron.ts Normal file
View File

@@ -0,0 +1,37 @@
import { CronJob } from "cron"
import path from "path"
import fs from "fs"
import { Cron } from "interfaces"
export default function loadCronEvents() {
const cronPath = path.join(__dirname, "..", "..", "events", "cron")
const cronFiles = fs
.readdirSync(cronPath)
.filter(file => file.endsWith(".js"))
for (const file of cronFiles) {
const filePath = path.join(cronPath, file)
const cron: Cron = require(filePath)
const time =
cron.time.seconds +
" " +
cron.time.minutes +
" " +
cron.time.hours +
" " +
cron.time.dayOfMonth +
" " +
cron.time.month +
" " +
cron.time.dayOfWeek
new CronJob(
time,
cron.execute,
cron.onComplete,
cron.start,
cron.timeZone,
).start()
}
}