-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify.js
More file actions
27 lines (24 loc) · 678 Bytes
/
Copy pathnotify.js
File metadata and controls
27 lines (24 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { IncomingWebhook } = require("@slack/webhook");
require("dotenv").config();
const webhookUrl = `https://hooks.slack.com/services/${process.env.SLACK_WEB_HOOK}`;
const webhook = new IncomingWebhook(webhookUrl);
async function notifySlack(message, date) {
try {
await webhook.send({
text: message,
attachments: [
{
text: date,
color: "#00FF00",
},
],
});
console.log("Notification sent to Slack!");
} catch (error) {
console.error("Error sending to Slack:", error);
}
}
notifySlack(
`Backup database ${process.env.DB_NAME} completed! :rocket:`,
`Success on: ${new Date().toISOString()}`
);