I want to make bot that know what day is today, i have example code below but i dont know how to fix this.
client.on("message", msg =>{
if (msg.content === "!today"){
If (Today is Sunday){
msg.reply("Time to Holiday")
}
else if(Today is monday){
msg.reply("Time to work")
}
}
});
>Solution :
new Date() gives you the current date and time. It has a method .getDay() which gives you the day of the week as a number. Sunday is 0; Monday is 1. So:
const dayOfWeek = new Date().getDay();
if (dayOfWeek === 0) { // is it Sunday?
Note that this is the bot server date and time. Different users might be on different days, due to time zones.