blob: 4e9e6feb30e57f67344206d892c51779aa01d470 [file] [log] [blame]
pineafanad54d752022-04-18 19:01:43 +01001import readConfig from "./readConfig.js";
2import generateEmojiEmbed from "./generateEmojiEmbed.js";
3
4let severities = {
5 "Critical": "Danger",
6 "Warning": "Warning",
7 "Info": "Success"
8}
9
10export default async function(client, type: string, guild: string, message: string, severity: string) {
11 let config = await readConfig(guild);
12 if (config.singleEventNotifications[type]) return;
13 // TODO: Set config.singleEventNotifications[type] to true
14 let channel = await client.channels.fetch(config.logging.staff);
15 if (!channel) return;
16 try {
17 await channel.send({embeds: [new generateEmojiEmbed()
18 .setTitle(`${severity} notification`)
19 .setDescription(message)
20 .setColor(severities[severity])
21 .setEmoji("CONTROL.BLOCKCROSS")
22 ]})
23 } catch (err) {
24 console.error(err)
25 }
26}