blob: f29d7756a44c363250b086ff0f3d4386b437c882 [file] [log] [blame]
import client from './client.js';
import EmojiEmbed from "./generateEmojiEmbed.js";
let severities = {
"Critical": "Danger",
"Warning": "Warning",
"Info": "Success"
}
export default async function(type: string, guild: string, message: string | true, severity?: string) {
let data = await client.database.guilds.read(guild);
if (message === true) {
return await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: false});
}
if (data.singleEventNotifications[type]) return;
await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: true});
try {
let channel = await client.channels.fetch(data.logging.staff.channel);
if (!channel) return;
await channel.send({embeds: [new EmojiEmbed()
.setTitle(`${severity} notification`)
.setDescription(message)
.setStatus(severities[severity])
.setEmoji("CONTROL.BLOCKCROSS")
]})
} catch (err) {
console.error(err)
}
}