[英]How to have discord.js send a dm to someone
I want it to send at a specific time.我希望它在特定时间发送。 I have that part worked out with cron.
我已经用 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.如果使用 v11,这应该适用于某些人。
If you are using v12:如果您使用的是 v12:
client.users.cache.get
client.users.cache.get
fetch
.fetch
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.