I'm looking to automate bot messages for specific times. For example:
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("ready", () => {
console.log("Bot is Online!");
});
var now = new Date();
var hour = now.getUTCHours();
var minute = now.getUTCMinutes();
client.on("message", (message) => {
if (hour === 10 && minute === 30) {
client.channels.get("ChannelID").send("Hello World!");
}
});
However, it seems to only work when triggered by another command like:
if (message.content.startsWith("!ping")) {
message.channel.send("pong!");
}
my message: !ping (at 10:10 o'clock)
-> pong!
-> Hello World!
I suppose I need something that continuously checks the time variables.