import cron from "node-cron"; import { config } from "../config.js"; import { db } from "../db/client.js"; import { gameNightService } from "../services/gameNightService.js"; export const scheduler = { start() { const expression = `${config.notifyMinute} ${config.notifyHour} * * *`; cron.schedule( expression, async () => { const guild = db .prepare("SELECT id FROM guilds WHERE discord_guild_id = ?") .get(config.discordGuildId) as { id: number } | undefined; if (!guild) return; await gameNightService.runMorningNotification(guild.id); }, { timezone: config.timezone } ); console.log(`Scheduler active on ${expression} (${config.timezone})`); } };