import cron from "node-cron"; import { TextChannel } from "discord.js"; // Lock poll at TG start (20:00), reveal Submit Score button at TG end (20:35) // Runs daily — no-ops silently if no poll is active for that slot. cron.schedule("0 20 * * *", async () => { const slot = 20; const state = polls.get(slot); if (!state || state.locked) return; lockPoll(slot); const channel = await client.channels.fetch(cfg("pollChannelId")) as TextChannel; await updatePollMessage(channel, slot, cfg("lockMessage")); console.log(`[${new Date().toISOString()}] Poll locked for ${slot}:00.`); }); cron.schedule("35 20 * * *", async () => { const slot = 20; const state = polls.get(slot); if (!state) return; const channel = await client.channels.fetch(cfg("pollChannelId")) as TextChannel; await updatePollMessage(channel, slot, undefined, true); // showSubmit = true console.log(`[${new Date().toISOString()}] Submit Score button shown for ${slot}:00 TG.`); }); // ─── NOTE on future slots ───────────────────────────────────────────────────── // // Right now only slot 20 has an active poll. When we add more votable slots, // pull the active slot from cfg("slots").filter(s => s.active) and schedule // dynamically, or make the cron time configurable in config.json.