Reputation: 11
A friend and I are trying to use Node Scheduler to have a discord bot announce things on certain days (Essentially a holiday calendar). We want it to post one pre set message, but it seems to post the messages a random amount of times.
var Hb = schedule.scheduleJob('* 6 14 20 4 *', function(){
bot.channels.get('435858985501982720').send('new message 3');
});
This is our tester code, does anyone know what's wrong?
Edit: we do want specific minutes, idk if that has any affect.
Upvotes: 1
Views: 121
Reputation: 3674
The first argument of schedule.scheduleJob
is a string representing when the function should fire, in cron format. According to the documentation you are trying to run the function:
aka every second at 2:06pm on 20th April every year.
I would rewrite the cron string using the format the docs provided:
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ │
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)
e.g. to run at midday on Christmas every year:
schedule.scheduleJob('0 0 12 25 12 *', function(){
bot.channels.get('435858985501982720').send('new message 3');
});
Upvotes: 1