Guest User

Untitled

a guest
Dec 17th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const client = new Discord.Client();
  3. client.on("ready", () => {
  4. console.log("Online!");
  5. });
  6. var now = new Date();
  7. var hour = now.getUTCHours();
  8. var minute = now.getUTCMinutes();
  9. client.on("message", (message) => {
  10. if (hour === 10 && minute === 30) {
  11. client.channels.get("ChannelID").send("Hello World!");
  12. }
  13. });
  14.  
  15. if (message.content.startsWith("!ping")) {
  16. message.channel.send("pong!");
  17. }
  18.  
  19. var cron = require("cron");
  20.  
  21. function test() {
  22. console.log("Action executed.");
  23. }
  24.  
  25. let job1 = new cron.CronJob('01 05 01,13 * * *', test); // fires every day, at 01:05:01 and 13:05:01
  26. let job2 = new cron.CronJob('00 00 08-16 * * 1-5', test); // fires from Monday to Friday, every hour from 8 am to 16
  27.  
  28. // To make a job start, use job.start()
  29. job1.start();
  30. // If you want to pause your job, use job.stop()
  31. job1.stop();
  32.  
  33. const cron = require('cron');
  34.  
  35. client.on('message', ...); // You don't need to add anything to the message event listener
  36.  
  37. let scheduledMessage = new cron.CronJob('00 30 10 * * *', () => {
  38. // This runs every day at 10:30:00, you can do anything you want
  39. let channel = yourGuild.channels.get('id');
  40. channel.send('You message');
  41. });
  42.  
  43. // When you want to start it, use:
  44. scheduledMessage.start()
  45. // You could also make a command to pause and resume the job
Add Comment
Please, Sign In to add comment