Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const client = new Discord.Client();
- client.on("ready", () => {
- console.log("Online!");
- });
- var now = new Date();
- var hour = now.getUTCHours();
- var minute = now.getUTCMinutes();
- client.on("message", (message) => {
- if (hour === 10 && minute === 30) {
- client.channels.get("ChannelID").send("Hello World!");
- }
- });
- if (message.content.startsWith("!ping")) {
- message.channel.send("pong!");
- }
- var cron = require("cron");
- function test() {
- console.log("Action executed.");
- }
- let job1 = new cron.CronJob('01 05 01,13 * * *', test); // fires every day, at 01:05:01 and 13:05:01
- let job2 = new cron.CronJob('00 00 08-16 * * 1-5', test); // fires from Monday to Friday, every hour from 8 am to 16
- // To make a job start, use job.start()
- job1.start();
- // If you want to pause your job, use job.stop()
- job1.stop();
- const cron = require('cron');
- client.on('message', ...); // You don't need to add anything to the message event listener
- let scheduledMessage = new cron.CronJob('00 30 10 * * *', () => {
- // This runs every day at 10:30:00, you can do anything you want
- let channel = yourGuild.channels.get('id');
- channel.send('You message');
- });
- // When you want to start it, use:
- scheduledMessage.start()
- // You could also make a command to pause and resume the job
Add Comment
Please, Sign In to add comment