-2

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);
Kugirea
  • 15
  • 3
  • 1
    Does this answer your question? [Call a javascript function at a specific time of day](https://stackoverflow.com/questions/4455282/call-a-javascript-function-at-a-specific-time-of-day) – pipebits Nov 20 '20 at 03:55
  • Does this answer your question? [Sending private messages to user](https://stackoverflow.com/questions/41745070/sending-private-messages-to-user) – Ido Nov 20 '20 at 04:32

1 Answers1

-1

This should work for some people if using v11.


If you are using v12:

  1. Use client.users.cache.get
  2. If it still doesn't work you need to use fetch.
wscourge
  • 10,657
  • 14
  • 59
  • 80
Kugirea
  • 15
  • 3