pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 1 | import readConfig from "./readConfig.js"; |
| 2 | import generateEmojiEmbed from "./generateEmojiEmbed.js"; |
| 3 | |
| 4 | let severities = { |
| 5 | "Critical": "Danger", |
| 6 | "Warning": "Warning", |
| 7 | "Info": "Success" |
| 8 | } |
| 9 | |
| 10 | export 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 | } |