I want it to send at a specific time. I have that part worked out with cron. I dont know how create a function that actually sends the message from the bot.
const Discord = require('discord.js');
const client = new Discord.Client();
var cron = require("cron");
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
let scheduledMessage = new cron.CronJob("30 52 20 * * *", () => {
client.users.get('ID').send('test');
})
scheduledMessage.start();
client.login(token);
This should work for some people if using v11.
If you are using v12:
client.users.cache.get
fetch
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.