Skip to content

Instantly share code, notes, and snippets.

@mikkipastel
Last active March 14, 2024 03:46
Show Gist options
  • Save mikkipastel/9a5057cef02a4440dfa14eb75cb5caa7 to your computer and use it in GitHub Desktop.
Save mikkipastel/9a5057cef02a4440dfa14eb75cb5caa7 to your computer and use it in GitHub Desktop.
sample for cronjob in Discord.js for alert with standup meeting
const cron = require('node-cron');
const Discord = require("discord.js");
const client = new Discord.Client();
client.once('ready', async () => {
common.log('Ready!');
try {
const webhook = new Discord.WebhookClient(process.env.WEBHOOK_ID, process.env.WEBOOK_TOKEN);
await cron.schedule('30 10 * * Mon-Fri', () => {
common.log('Trigger standup meeting schedule');
webhook.send('@everyone, standup meeting', {
username: 'BB-8',
avatarURL: 'https://i.imgur.com/PHnLYAm.png'
});
});
} catch (error) {
common.error('Error trying to send: ', error);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment