[英]How to make a message send on certain days and hours on discord.js v13
我所有的代碼都還沒有工作,想知道我該怎么做
你問的方式對於堆棧溢出來說太寬泛了,就像用戶@kevintechie所說的那樣。 無論如何,要在特定時間發送消息,我建議使用Cron
Cron 的可能變量是:
秒數:0-59
分鍾:0-59
小時:0-23
日期:1-31
月份:0-11(一月至十二月)
星期幾:0-6(周日至周六)
假設您想使用當地時間每天早上 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()
否則,如果您希望它從周一到周五提醒,那么它將是...new cron.CronJob('00 00 06 * * 1-5', ()=> {...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.