blob: a98347884d58573e752d6e061988e2c8eb904025 [file] [log] [blame]
pineafan6702cef2022-06-13 17:52:37 +01001import client from './client.js';
pineafanad54d752022-04-18 19:01:43 +01002import generateEmojiEmbed from "./generateEmojiEmbed.js";
3
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) {
11 let data = await client.database.read(guild);
12 if (data.singleEventNotifications[type]) return;
13 data.singleEventNotifications[type] = true;
14 client.database.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;
pineafanad54d752022-04-18 19:01:43 +010018 await channel.send({embeds: [new generateEmojiEmbed()
19 .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}