Discord bot (nodejs) Tasks

Hi guys, I’m trying to make a function in my discord bot.
Let the bot tell me if there is maintenance at a specific time.
But I want to automate this task …

I would be very helpful if someone knows how I can solve this … cus I’m stuck for a week …

  switch (day) {
    case 1:
      msg.channel.send("Luni este maintenance la ora 3:30 am.")
    case 2:
      msg.channel.send("Marti nu este maintenance.")
    case 3:
      msg.channel.send("Miercuri este maintenance la ora 3:30 am.")
    case 4:
      msg.channel.send("Joi nu este maintenance.")
    case 5:
      msg.channel.send("Vineri este maintenance la ora 2:00 am.")
    case 6:
      msg.channel.send("Sambata este maintenance la ora 2:00 am.")
    case 7:
      msg.channel.send("Duminica nu este maintenance.")

the #support subforum is only for technical difficulties with the website itself, please avoid using it to ask for help with your own code
I am moving your thread to #help

@aziime you have to give us more information. Can you explain why are you approaching this challenge using a Switch?

1 Like

More information would be helpful.

If, for example, you had this in a command response inside the message handler. (which is where you would get the message.channel from)
i.e. anyone types !uptime

what you have is almost correct; depending on what you have for day. Days are 0 based, so 0-6.

switch (new Date().getDay()) {

So your bot will respond to !uptime with the message listed in your switch with the case that matches the “Day” (the time of the host server).

if you are looking for a second argument, !uptime Monday, then that would be slightly different. Times are difficult to mange with servers that have users over a broad area. so your 2AM might me 10pm for me. I would suggest a UTC/GMT time baseline, but that is off topic…

I guess, @Hash2C said it best. need more code to see what is triggering the event and the arguments expected.