Last active
March 14, 2024 03:46
-
-
Save mikkipastel/9a5057cef02a4440dfa14eb75cb5caa7 to your computer and use it in GitHub Desktop.
sample for cronjob in Discord.js for alert with standup meeting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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