Sending message to a specific channel at a specific time using cron in Discord

I want to send a message to a specific channel at 2:00 AM in Discord. I can't get it to work. Am I doing something wrong?

Here's my code:

const Discord = require("discord.js")
const cron = require("cron")
const client = new Discord.Client()
let channel = "ID#"

let job = new cron.CronJob('0 00 2 * * *', () => {
client.channels.cache.get(channel).send("Hello!!")

job.start()

client.login("Server#")


Read more here: https://stackoverflow.com/questions/68490149/sending-message-to-a-specific-channel-at-a-specific-time-using-cron-in-discord

Content Attribution

This content was originally published by user874737 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: