[英]How to make a message send on certain days and hours on discord.js v13
All my code hasn't worked yet and was wondering how I could do it我所有的代码都还没有工作,想知道我该怎么做
The way you ask is too broad for Stack overflow, like what user @kevintechie said.你问的方式对于堆栈溢出来说太宽泛了,就像用户@kevintechie所说的那样。 Anyway, for sending a message at a specific time, I recommend using Cron
无论如何,要在特定时间发送消息,我建议使用Cron
The possible varibles of Cron are: Cron 的可能变量是:
Seconds: 0-59秒数:0-59
Minutes: 0-59分钟:0-59
Hours: 0-23小时:0-23
Day of Month: 1-31日期:1-31
Months: 0-11 (January - December)月份:0-11(一月至十二月)
Day of Week: 0-6 (Sunday - Saturday)星期几:0-6(周日至周六)
Lets say you want to send a message everyday at 6 AM, using your local time假设您想使用当地时间每天早上 6 点发送一条消息
var cron = require("cron");
client.on('message', ...); //you don't have to add anything to the message listener
let morning = new cron.CronJob('00 00 06 * * *', () => {
// Everyday at 6 AM, it will do something you want to it to do
let channel = yourGuild.channels.get('id');
channel.send('Morning everyone');
});
// to start the reminder
morning.start()
// to stop the reminder
morning.stop()
Else if you want it to remind from Mon to Fri, then it would be ...new cron.CronJob('00 00 06 * * 1-5', ()=> {...
否则,如果您希望它从周一到周五提醒,那么它将是
...new cron.CronJob('00 00 06 * * 1-5', ()=> {...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.