blob: 051ec4d94cad81d1c2ac8e0d2e4442af6265ef85 [file] [log] [blame]
pineafan6702cef2022-06-13 17:52:37 +01001import client from './client.js';
pineafan4edb7762022-06-26 19:21:04 +01002import EmojiEmbed from "./generateEmojiEmbed.js";
pineafanad54d752022-04-18 19:01:43 +01003
4let severities = {
5 "Critical": "Danger",
6 "Warning": "Warning",
7 "Info": "Success"
8}
9
pineafan6702cef2022-06-13 17:52:37 +010010export default async function(type: string, guild: string, message: string, severity: string) {
pineafan4edb7762022-06-26 19:21:04 +010011 let data = await client.database.guilds.read(guild);
pineafan6702cef2022-06-13 17:52:37 +010012 if (data.singleEventNotifications[type]) return;
13 data.singleEventNotifications[type] = true;
pineafan4edb7762022-06-26 19:21:04 +010014 client.database.guilds.write(guild, data);
pineafanad54d752022-04-18 19:01:43 +010015 try {
pineafan6702cef2022-06-13 17:52:37 +010016 let channel = await client.channels.fetch(data.logging.staff.channel);
17 if (!channel) return;
pineafan4edb7762022-06-26 19:21:04 +010018 await channel.send({embeds: [new EmojiEmbed()
pineafanad54d752022-04-18 19:01:43 +010019 .setTitle(`${severity} notification`)
20 .setDescription(message)
pineafan6702cef2022-06-13 17:52:37 +010021 .setStatus(severities[severity])
pineafanad54d752022-04-18 19:01:43 +010022 .setEmoji("CONTROL.BLOCKCROSS")
23 ]})
24 } catch (err) {
25 console.error(err)
26 }
27}