module.exports = { timeout: 1000, immediate: false, name: 'Receipt Day Announcements', data: { channelId: '1462060674766344370', targetHour: 0, targetMinute: 1 }, async tick(client, timer) { try { // 1. Send the message const currentDate = new Date().toLocaleDateString('en-GB', { weekday: 'long', day: '2-digit', month: '2-digit', year: 'numeric' }); const channel = await client.channels.fetch(timer.data.channelId); if (channel) await channel.send(`Today is ${currentDate}`); } catch (error) { console.error('[TIMER] Error:', error); } finally { // 2. Schedule the NEXT tick manually this.scheduleNext(client, timer); } }, scheduleNext(client, timer) { const now = new Date(); const next = new Date(); next.setHours(timer.data.targetHour, timer.data.targetMinute, 0, 0); if (next <= now) { next.setDate(next.getDate() + 1); } const delay = next.getTime() - now.getTime(); if (timer.instance) clearTimeout(timer.instance); timer.instance = setTimeout(() => { this.tick(client, timer); }, delay); console.log(`[TIMER] Next message scheduled for: ${next.toLocaleString()}`); } };