Discord bot automatic daily messages excluding weekends not working

I’m working on a Discord bot that should automatically post messages to a channel once per day, but not on weekends. My current approach isn’t functioning properly and I can’t figure out what’s wrong.

Here’s what I’ve tried so far:

const bot = new Discord.Client();
bot.on("ready", () => {
  console.log("Bot is running!");
});

var currentTime = new Date();
var currentHour = currentTime.getUTCHours();
var currentMinute = currentTime.getUTCMinutes();

bot.on("message", (msg) => {
  if (currentHour === 14 && currentMinute === 0) {
    bot.channels.get("your-channel-id").send("Daily reminder message!");
  }
});

The bot connects fine but the scheduled message never gets sent. I think there might be an issue with how I’m handling the time checking or maybe the event listener isn’t the right approach. Any suggestions on how to fix this would be really helpful!

Your main problem is you’re treating this like an event instead of a background task. Those time variables get calculated once when the bot starts, and checking inside the message event means nothing happens unless someone’s actively chatting.

I hit the same issue building notification bots. What fixed it for me was using setInterval to check the time every minute, then compare against your target time while skipping weekends.

Try this:

setInterval(() => {
  const now = new Date();
  const dayOfWeek = now.getUTCDay();
  
  if (dayOfWeek >= 1 && dayOfWeek <= 5 && now.getUTCHours() === 14 && now.getUTCMinutes() === 0) {
    bot.channels.cache.get("your-channel-id").send("Daily reminder message!");
  }
}, 60000);

Btw, bot.channels.get() is deprecated - use bot.channels.cache.get() instead. The interval approach keeps everything self-contained without needing external services or complicated scheduling libraries.

Had this same issue last month. your currentTime variables only run once when the bot starts - they don’t update after that. plus you’re checking inside message events, so if there’s no chat activity, nothing executes. quick fix is setTimeout in a loop, but watch out for DST changes or your timing will drift. also, ditch that old channels.get() method and use channels.cache.get() instead.

Been there with Discord scheduling headaches. Your time calculation runs once at startup and never updates. Plus you’re checking inside message events, so no activity means no execution.

I switched to node-schedule after hitting the same issues. Way more reliable than setInterval for this stuff. It handles weekday filtering naturally and won’t drift like manual date checking.

const schedule = require('node-schedule');

schedule.scheduleJob('0 14 * * 1-5', () => {
  bot.channels.cache.get('your-channel-id').send('Daily reminder message!');
});

This cron expression skips weekends and fires at 2 PM on weekdays. No manual day-of-week calculations or edge cases to handle. Just check your server timezone matches what you want, or your 2 PM becomes someone else’s midnight.

Your time variables are static - they grab the startup time and never update. You’re also checking inside the message event, so your bot only looks at timing when people are chatting.

I hit the same issue building automated status updates. A simple timeout-based recursive function worked way better than intervals or external libraries:

function scheduleNext() {
  const now = new Date();
  const tomorrow = new Date(now);
  tomorrow.setUTCDate(now.getUTCDate() + 1);
  tomorrow.setUTCHours(14, 0, 0, 0);
  
  const delay = tomorrow.getTime() - now.getTime();
  
  setTimeout(() => {
    const day = new Date().getUTCDay();
    if (day >= 1 && day <= 5) {
      bot.channels.cache.get('your-channel-id').send('Daily reminder message!');
    }
    scheduleNext();
  }, delay);
}

bot.on('ready', () => {
  console.log('Bot is running!');
  scheduleNext();
});

This calculates exact milliseconds until your target time and schedules it perfectly. No constant polling or checking every minute.

The problem is you’re only checking time when someone sends a message. Your time variables get set once at startup and never update. Also, the message event is the wrong spot for scheduling.

You need a proper scheduler running continuously that checks for weekdays. I hit this exact issue building automated reporting bots at work.

Instead of fighting with cron jobs or messy JavaScript timing, I switched to Latenode for Discord automation. Set up a workflow that triggers daily at your time, filters out weekends, and sends directly to your Discord channel.

Best part? You don’t need your bot running 24/7 just for scheduling. Latenode handles timing and only hits your Discord webhook when needed. Way cleaner than managing intervals and date logic in bot code.

Set it once and forget it. No more debugging timing issues or worrying about server downtime missing scheduled messages.

your code’s got timing issues and you’re missing weekend exclusion entirely. that message event approach won’t work - it only triggers when users type, not continuously. ditch setInterval and use node-cron instead. way cleaner for scheduling stuff. try cron.schedule('0 14 * * 1-5') - handles weekdays automatically. also double-check your timezone settings. utc probably doesn’t match what you actually need.

Yeah, your main problem is the time check only runs when users send messages. No chat activity = no scheduled messages.

I hit this same issue building notification systems. Tried intervals and cron libraries but they’re more trouble than they’re worth. Your bot needs 24/7 uptime, timezone handling gets weird, and debugging timing stuff sucks.

Better approach: move scheduling outside your bot completely. I use Latenode for Discord automation now. Set up a workflow that triggers Monday-Friday at your target time, then posts to your channel via webhook.

No bot sitting around checking the clock every minute. No timezone math breaking on daylight savings. The workflow runs in the cloud and only fires when it needs to send your message.

Let your bot handle user interactions while Latenode does the scheduling grunt work. Way cleaner.