diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index fa66755..c4c1347 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -1,71 +1,70 @@
-export const event = 'channelCreate'
+export const event = "channelCreate";
 
 export async function callback(client, channel) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
-        let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let emoji;
-        let readableType;
-        let displayName;
-        switch (channel.type) {
-            case 'GUILD_TEXT': {
-                emoji = "CHANNEL.TEXT.CREATE";
-                readableType = "Text";
-                displayName = "Text Channel"
-                break;
-            }
-            case 'GUILD_NEWS': {
-                emoji = "CHANNEL.TEXT.CREATE";
-                readableType = "Announcement";
-                displayName = "Announcement Channel"
-                break;
-            }
-            case 'GUILD_VOICE': {
-                emoji = "CHANNEL.VOICE.CREATE";
-                readableType = "Voice";
-                displayName = "Voice Channel"
-                break;
-            }
-            case 'GUILD_STAGE': {
-                emoji = "CHANNEL.VOICE.CREATE";
-                readableType = "Stage";
-                displayName = "Stage Channel"
-            }
-            case 'GUILD_CATEGORY': {
-                emoji = "CHANNEL.CATEGORY.CREATE";
-                readableType = "Category";
-                displayName = "Category"
-                break;
-            }
-            default: {
-                emoji = "CHANNEL.TEXT.CREATE";
-                readableType = "Channel";
-                displayName = "Channel"
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger;
+    const auditLog = await getAuditLog(channel.guild, "CHANNEL_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+    if (audit.executor.id === client.user.id) return;
+    let emoji;
+    let readableType;
+    let displayName;
+    switch (channel.type) {
+    case "GUILD_TEXT": {
+        emoji = "CHANNEL.TEXT.CREATE";
+        readableType = "Text";
+        displayName = "Text Channel";
+        break;
+    }
+    case "GUILD_NEWS": {
+        emoji = "CHANNEL.TEXT.CREATE";
+        readableType = "Announcement";
+        displayName = "Announcement Channel";
+        break;
+    }
+    case "GUILD_VOICE": {
+        emoji = "CHANNEL.VOICE.CREATE";
+        readableType = "Voice";
+        displayName = "Voice Channel";
+        break;
+    }
+    case "GUILD_STAGE": {
+        emoji = "CHANNEL.VOICE.CREATE";
+        readableType = "Stage";
+        displayName = "Stage Channel";
+        break;
+    }
+    case "GUILD_CATEGORY": {
+        emoji = "CHANNEL.CATEGORY.CREATE";
+        readableType = "Category";
+        displayName = "Category";
+        break;
+    }
+    default: {
+        emoji = "CHANNEL.TEXT.CREATE";
+        readableType = "Channel";
+        displayName = "Channel";
+    }
+    }
+    const data = {
+        meta: {
+            type: "channelCreate",
+            displayName: displayName + " Created",
+            calculateType: "channelUpdate",
+            color: NucleusColors.green,
+            emoji: emoji,
+            timestamp: channel.createdTimestamp
+        },
+        list: {
+            channelId: entry(channel.id, `\`${channel.id}\``),
+            name: entry(channel.name, renderChannel(channel)),
+            type: entry(channel.type, readableType),
+            category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
+        },
+        hidden: {
+            guild: channel.guild.id
         }
-        let data = {
-            meta: {
-                type: 'channelCreate',
-                displayName: displayName + ' Created',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.green,
-                emoji: emoji,
-                timestamp: channel.createdTimestamp
-            },
-            list: {
-                channelId: entry(channel.id, `\`${channel.id}\``),
-                name: entry(channel.name, renderChannel(channel)),
-                type: entry(channel.type, readableType),
-                category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
-            },
-            hidden: {
-                guild: channel.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index 25c9ce5..c8a72a4 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -1,73 +1,71 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'channelDelete'
+export const event = "channelDelete";
 
 export async function callback(client, channel) {
-    try{
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger;
 
-        let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
-        if (audit.executor.id === client.user.id) return;
+    const auditLog = await getAuditLog(channel.guild, "CHANNEL_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+    if (audit.executor.id === client.user.id) return;
 
-        let emoji;
-        let readableType;
-        let displayName;
-        switch (channel.type) {
-            case 'GUILD_TEXT': {
-                emoji = "CHANNEL.TEXT.DELETE";
-                readableType = "Text";
-                displayName = "Text Channel"
-                break;
-            }
-            case 'GUILD_VOICE': {
-                emoji = "CHANNEL.VOICE.DELETE";
-                readableType = "Voice";
-                displayName = "Voice Channel"
-                break;
-            }
-            case 'GUILD_CATEGORY': {
-                emoji = "CHANNEL.CATEGORY.DELETE";
-                readableType = "Category";
-                displayName = "Category"
-                break;
-            }
-            default: {
-                emoji = "CHANNEL.TEXT.DELETE";
-                readableType = "Channel";
-                displayName = "Channel"
-            }
-        }
-        let list = {
-            channelId: entry(channel.id, `\`${channel.id}\``),
-            name: entry(channel.id, `${channel.name}`),
-            topic: null,
-            type: entry(channel.type, readableType),
-            category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
-            nsfw: null,
-            created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
-            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            deletedBy: entry(audit.executor.id, renderUser(audit.executor))
-        }
-        if (channel.topic !== null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
-        else delete list.topic;
-        if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
-        else delete list.nsfw;
+    let emoji;
+    let readableType;
+    let displayName;
+    switch (channel.type) {
+    case "GUILD_TEXT": {
+        emoji = "CHANNEL.TEXT.DELETE";
+        readableType = "Text";
+        displayName = "Text Channel";
+        break;
+    }
+    case "GUILD_VOICE": {
+        emoji = "CHANNEL.VOICE.DELETE";
+        readableType = "Voice";
+        displayName = "Voice Channel";
+        break;
+    }
+    case "GUILD_CATEGORY": {
+        emoji = "CHANNEL.CATEGORY.DELETE";
+        readableType = "Category";
+        displayName = "Category";
+        break;
+    }
+    default: {
+        emoji = "CHANNEL.TEXT.DELETE";
+        readableType = "Channel";
+        displayName = "Channel";
+    }
+    }
+    const list = {
+        channelId: entry(channel.id, `\`${channel.id}\``),
+        name: entry(channel.id, `${channel.name}`),
+        topic: null,
+        type: entry(channel.type, readableType),
+        category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+        nsfw: null,
+        created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+        deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+        deletedBy: entry(audit.executor.id, renderUser(audit.executor))
+    };
+    if (channel.topic !== null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace("`", "'")}\n\`\`\``);
+    else delete list.topic;
+    if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
+    else delete list.nsfw;
 
-        let data = {
-            meta:{
-                type: 'channelDelete',
-                displayName: displayName + ' Deleted',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.red,
-                emoji: emoji,
-                timestamp: audit.createdTimestamp
-            },
-            list: list,
-            hidden: {
-                guild: channel.guild.id
-            }
+    const data = {
+        meta:{
+            type: "channelDelete",
+            displayName: displayName + " Deleted",
+            calculateType: "channelUpdate",
+            color: NucleusColors.red,
+            emoji: emoji,
+            timestamp: audit.createdTimestamp
+        },
+        list: list,
+        hidden: {
+            guild: channel.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 568af0b..89692e8 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -1,135 +1,133 @@
-import humanizeDuration from 'humanize-duration';
-import getEmojiByName from '../utils/getEmojiByName.js';
+import humanizeDuration from "humanize-duration";
+import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'channelUpdate';
+export const event = "channelUpdate";
 
 export async function callback(client, oc, nc) {
-    try {
-        let config = await client.memory.readGuildInfo(nc.guild.id);
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
+    const config = await client.memory.readGuildInfo(nc.guild.id);
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger;
 
-        if (nc.parent && (nc.parent.id === config.tickets.category)) return
+    if (nc.parent && (nc.parent.id === config.tickets.category)) return;
 
-        let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
-        if (audit.executor.id === client.user.id) return;
+    const auditLog = await getAuditLog(nc.guild, "CHANNEL_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
+    if (audit.executor.id === client.user.id) return;
 
-        let emoji:string;
-        let readableType:string;
-        let displayName:string ;
-        let changes = {
-            channelId: entry(nc.id, `\`${nc.id}\``),
-            channel: entry(nc.id, renderChannel(nc)),
-            edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
+    let emoji:string;
+    let readableType:string;
+    let displayName:string ;
+    const changes = {
+        channelId: entry(nc.id, `\`${nc.id}\``),
+        channel: entry(nc.id, renderChannel(nc)),
+        edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+        editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user))
+    };
+    if (oc.name !== nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+    if (oc.position !== nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
+
+    switch (nc.type) {
+    case "GUILD_TEXT": {
+        emoji = "CHANNEL.TEXT.EDIT";
+        readableType = "Text";
+        displayName = "Text Channel";
+        let oldTopic = oc.topic, newTopic = nc.topic;
+        if (oldTopic) {
+            if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+        } else { oldTopic = "None"; }
+        if (newTopic) {
+            if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+        } else { newTopic = "None"; }
+        const nsfw = ["", ""];
+        nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+        nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+        if (oc.topic !== nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+        if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
+        if (oc.rateLimitPerUser !== nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
+            [oc.rateLimitPerUser, nc.rateLimitPerUser],
+            `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
+        );
+
+        break;
+    }
+    case "GUILD_NEWS": {
+        emoji = "CHANNEL.TEXT.EDIT";
+        readableType = "News";
+        displayName = "News Channel";
+        let oldTopic = oc.topic, newTopic = nc.topic;
+        if (oldTopic) {
+            if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+        } else { oldTopic = "None"; }
+        if (newTopic) {
+            if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+        } else { newTopic = "None"; }
+        if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
+        break;
+    }
+    case "GUILD_VOICE": {
+        emoji = "CHANNEL.VOICE.EDIT";
+        readableType = "Voice";
+        displayName = "Voice Channel";
+        if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+        if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+        if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
+            [oc.rtcRegion, nc.rtcRegion],
+            `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+        );
+        break;
+    }
+    case "GUILD_STAGE": {
+        emoji = "CHANNEL.VOICE.EDIT";
+        readableType = "Stage";
+        displayName = "Stage Channel";
+        let oldTopic = oc.topic, newTopic = nc.topic;
+        if (oldTopic) {
+            if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+        } else { oldTopic = "None"; }
+        if (newTopic) {
+            if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+        } else { newTopic = "None"; }
+        if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+        if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+        if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
+            [oc.rtcRegion, nc.rtcRegion],
+            `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+        );
+        break;
+    }
+    case "GUILD_CATEGORY": {
+        emoji = "CHANNEL.CATEGORY.EDIT";
+        readableType = "Category";
+        displayName = "Category";
+        break;
+    }
+    default: {
+        emoji = "CHANNEL.TEXT.EDIT";
+        readableType = "Channel";
+        displayName = "Channel";
+    }
+    }
+    const t = oc.type.split("_")[1];
+    if (oc.type !== nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
+    if (!(Object.values(changes).length - 4)) return;
+    const data = {
+        meta:{
+            type: "channelUpdate",
+            displayName: displayName + " Edited",
+            calculateType: "channelUpdate",
+            color: NucleusColors.yellow,
+            emoji: emoji,
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: nc.guild.id
         }
-        if (oc.name !== nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
-        if (oc.position !== nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
-
-        switch (nc.type) {
-            case 'GUILD_TEXT': {
-                emoji = "CHANNEL.TEXT.EDIT";
-                readableType = "Text";
-                displayName = "Text Channel"
-                let oldTopic = oc.topic, newTopic = nc.topic;
-                if (oldTopic) {
-                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-                } else { oldTopic = "None"; }
-                if (newTopic) {
-                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-                } else { newTopic = "None"; }
-                let nsfw = ["", ""]
-                nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-                nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-                if (oc.topic !== nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
-                if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
-                if (oc.rateLimitPerUser !== nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
-                    [oc.rateLimitPerUser, nc.rateLimitPerUser],
-                    `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
-                );
-
-                break;
-            }
-            case 'GUILD_NEWS': {
-                emoji = "CHANNEL.TEXT.EDIT";
-                readableType = "News";
-                displayName = "News Channel"
-                let oldTopic = oc.topic, newTopic = nc.topic;
-                if (oldTopic) {
-                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-                } else { oldTopic = "None"; }
-                if (newTopic) {
-                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-                } else { newTopic = "None"; }
-                if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
-                break;
-            }
-            case 'GUILD_VOICE': {
-                emoji = "CHANNEL.VOICE.EDIT";
-                readableType = "Voice";
-                displayName = "Voice Channel"
-                if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
-                if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
-                if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
-                    [oc.rtcRegion, nc.rtcRegion],
-                    `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
-                );
-                break;
-            }
-            case 'GUILD_STAGE': {
-                emoji = "CHANNEL.VOICE.EDIT";
-                readableType = "Stage";
-                displayName = "Stage Channel"
-                let oldTopic = oc.topic, newTopic = nc.topic;
-                if (oldTopic) {
-                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-                } else { oldTopic = "None"; }
-                if (newTopic) {
-                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-                } else { newTopic = "None"; }
-                if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
-                if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
-                if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
-                    [oc.rtcRegion, nc.rtcRegion],
-                    `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
-                );
-                break;
-            }
-            case 'GUILD_CATEGORY': {
-                emoji = "CHANNEL.CATEGORY.EDIT";
-                readableType = "Category";
-                displayName = "Category"
-                break;
-            }
-            default: {
-                emoji = "CHANNEL.TEXT.EDIT";
-                readableType = "Channel";
-                displayName = "Channel"
-            }
-        }
-        let t = oc.type.split("_")[1];
-        if (oc.type !== nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
-        if (!(Object.values(changes).length - 4)) return
-        let data = {
-            meta:{
-                type: 'channelUpdate',
-                displayName: displayName + ' Edited',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.yellow,
-                emoji: emoji,
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: nc.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/commandError.ts b/src/events/commandError.ts
index 8edb480..2ec6a5d 100644
--- a/src/events/commandError.ts
+++ b/src/events/commandError.ts
@@ -1,6 +1,6 @@
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 
-export const event = 'commandError'
+export const event = "commandError";
 
 export async function callback(client, interaction, error) {
     if (interaction.replied || interaction.deferred) {
@@ -9,13 +9,13 @@
             .setDescription(error.message ?? error.toString())
             .setStatus("Danger")
             .setEmoji("CONTROL.BLOCKCROSS")
-        ], ephemeral: true})
+        ], ephemeral: true});
     } else {
         await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Something went wrong")
             .setDescription(error.message ?? error.toString())
             .setStatus("Danger")
             .setEmoji("CONTROL.BLOCKCROSS")
-        ], ephemeral: true})
+        ], ephemeral: true});
     }
 }
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 9e91012..83a30e2 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,30 +1,28 @@
-export const event = 'emojiCreate'
+export const event = "emojiCreate";
 
 export async function callback(client, emoji) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
-        let auditLog = await getAuditLog(emoji.guild, 'EMOJI_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'emojiCreate',
-                displayName: 'Emoji Created',
-                calculateType: 'emojiUpdate',
-                color: NucleusColors.green,
-                emoji: "GUILD.EMOJI.CREATE",
-                timestamp: emoji.createdTimestamp
-            },
-            list: {
-                emojiId: entry(emoji.id, `\`${emoji.id}\``),
-                emoji: entry(emoji.name, renderEmoji(emoji)),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "EMOJI_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "emojiCreate",
+            displayName: "Emoji Created",
+            calculateType: "emojiUpdate",
+            color: NucleusColors.green,
+            emoji: "GUILD.EMOJI.CREATE",
+            timestamp: emoji.createdTimestamp
+        },
+        list: {
+            emojiId: entry(emoji.id, `\`${emoji.id}\``),
+            emoji: entry(emoji.name, renderEmoji(emoji)),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 0c39542..5ed7a87 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,31 +1,29 @@
-export const event = 'emojiDelete'
+export const event = "emojiDelete";
 
 export async function callback(client, emoji) {
-    try{
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
-        let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'emojiDelete',
-                displayName: 'Emoji Deleted',
-                calculateType: 'emojiUpdate',
-                color: NucleusColors.red,
-                emoji: "GUILD.EMOJI.DELETE",
-                timestamp: audit.createdTimestamp,
-            },
-            list: {
-                emojiId: entry(emoji.id, `\`${emoji.id}\``),
-                emoji: entry(emoji.name, renderEmoji(emoji)),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
-                deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "EMOJI_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "emojiDelete",
+            displayName: "Emoji Deleted",
+            calculateType: "emojiUpdate",
+            color: NucleusColors.red,
+            emoji: "GUILD.EMOJI.DELETE",
+            timestamp: audit.createdTimestamp
+        },
+        list: {
+            emojiId: entry(emoji.id, `\`${emoji.id}\``),
+            emoji: entry(emoji.name, renderEmoji(emoji)),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+            deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index a90de9a..d04c6c8 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -1,37 +1,33 @@
-import getEmojiByName from "../utils/getEmojiByName.js";
-
-export const event = 'emojiUpdate';
+export const event = "emojiUpdate";
 
 export async function callback(client, oe, ne) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger;
 
-        if (oe.name === ne.name) return
-        let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
-        let audit = auditLog.entries.first();
-        if (audit.executor.id === client.user.id) return;
+    if (oe.name === ne.name) return;
+    const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
+    const audit = auditLog.entries.first();
+    if (audit.executor.id === client.user.id) return;
 
-        let changes = {
-            emojiId: entry(ne.id, `\`${ne.id}\``),
-            emoji: entry(ne.id, renderEmoji(ne)),
-            edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
-            editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
-            name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+    const changes = {
+        emojiId: entry(ne.id, `\`${ne.id}\``),
+        emoji: entry(ne.id, renderEmoji(ne)),
+        edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+        editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+        name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
+    };
+    const data = {
+        meta:{
+            type: "emojiUpdate",
+            displayName: "Emoji Edited",
+            calculateType: "emojiUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.EMOJI.EDIT",
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: ne.guild.id
         }
-        let data = {
-            meta:{
-                type: 'emojiUpdate',
-                displayName: 'Emoji Edited',
-                calculateType: 'emojiUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.EMOJI.EDIT",
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: ne.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index 06163a9..c5d269b 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -1,39 +1,37 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildBanAdd';
+export const event = "guildBanAdd";
 
 export async function callback(client, ban) {
-    try { await statsChannelRemove(client, ban.user); } catch {}
-    try { purgeByUser(ban.user.id, ban.guild); } catch {}
-    try {
-        const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
-        let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_ADD')
-        let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
-        if (audit.executor.id === client.user.id) return
-        try { await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
-        let data = {
-            meta: {
-                type: 'memberBan',
-                displayName: 'Member Banned',
-                calculateType: 'guildMemberPunish',
-                color: NucleusColors.red,
-                emoji: "PUNISH.BAN.RED",
-                timestamp: new Date().getTime()
-            },
-            list: {
-                memberId: entry(ban.user.id, `\`${ban.user.id}\``),
-                name: entry(ban.user.id, renderUser(ban.user)),
-                banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
-                accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
-                serverMemberCount: ban.guild.memberCount,
-            },
-            hidden: {
-                guild: ban.guild.id
-            }
+    await statsChannelRemove(client, ban.user);
+    purgeByUser(ban.user.id, ban.guild);
+    const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+    const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_ADD");
+    const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+    if (audit.executor.id === client.user.id) return;
+    await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason);
+    const data = {
+        meta: {
+            type: "memberBan",
+            displayName: "Member Banned",
+            calculateType: "guildMemberPunish",
+            color: NucleusColors.red,
+            emoji: "PUNISH.BAN.RED",
+            timestamp: new Date().getTime()
+        },
+        list: {
+            memberId: entry(ban.user.id, `\`${ban.user.id}\``),
+            name: entry(ban.user.id, renderUser(ban.user)),
+            banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+            bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+            accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
+            serverMemberCount: ban.guild.memberCount
+        },
+        hidden: {
+            guild: ban.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 2a1b6de..352265f 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -1,38 +1,35 @@
-import humanizeDuration from 'humanize-duration';
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildBanRemove';
+export const event = "guildBanRemove";
 
 export async function callback(client, ban) {
-    try { await statsChannelRemove(client, ban.user); } catch {}
-    try { purgeByUser(ban.user.id, ban.guild); } catch {}
-    try {
-        const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
-        let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_REMOVE')
-        let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
-        if (audit.executor.id === client.user.id) return
-        try { await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
-        let data = {
-            meta: {
-                type: 'memberUnban',
-                displayName: 'Member Unbanned',
-                calculateType: 'guildMemberPunish',
-                color: NucleusColors.green,
-                emoji: "PUNISH.BAN.GREEN",
-                timestamp: new Date().getTime()
-            },
-            list: {
-                memberId: entry(ban.user.id, `\`${ban.user.id}\``),
-                name: entry(ban.user.id, renderUser(ban.user)),
-                unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
-            },
-            hidden: {
-                guild: ban.guild.id
-            }
+    await statsChannelRemove(client, ban.user);
+    purgeByUser(ban.user.id, ban.guild);
+    const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+    const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_REMOVE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+    if (audit.executor.id === client.user.id) return;
+    await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason);
+    const data = {
+        meta: {
+            type: "memberUnban",
+            displayName: "Member Unbanned",
+            calculateType: "guildMemberPunish",
+            color: NucleusColors.green,
+            emoji: "PUNISH.BAN.GREEN",
+            timestamp: new Date().getTime()
+        },
+        list: {
+            memberId: entry(ban.user.id, `\`${ban.user.id}\``),
+            name: entry(ban.user.id, renderUser(ban.user)),
+            unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+            unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt))
+        },
+        hidden: {
+            guild: ban.guild.id
         }
-        log(data);
-    } catch (e) {console.log(e)}
+    };
+    log(data);
 }
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index 413e5fb..8f8d0f5 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,12 +1,11 @@
-import { MessageActionRow, MessageButton } from "discord.js";
-import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../utils/getEmojiByName.js";
+import type { Guild } from "discord.js";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { HaikuClient } from "jshaiku";
 import guide from "../reflex/guide.js";
 
-export const event = 'guildCreate';
+export const event = "guildCreate";
 
-export async function callback(client, guild) {
-    try{
-        guide(guild)
-    } catch {}
+export async function callback(_client: HaikuClient, guild: Guild) {
+    guide(guild);
 }
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index d555647..a7f8c47 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -1,20 +1,20 @@
-export const event = 'guildMemberUpdate'
+export const event = "guildMemberUpdate";
 
 export async function callback(client, before, after) {
     try {
-        const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger
-        let auditLog = await getAuditLog(after.guild, 'MEMBER_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+        const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger;
+        const auditLog = await getAuditLog(after.guild, "MEMBER_UPDATE");
+        const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
         if (audit.executor.id === client.user.id) return;
         if (before.nickname !== after.nickname) {
-            try { await client.database.history.create(
+            await client.database.history.create(
                 "nickname", after.guild.id, after.user, audit.executor,
-                null, before.nickname || before.user.username, after.nickname || after.user.username) } catch {}
-            let data = {
+                null, before.nickname || before.user.username, after.nickname || after.user.username);
+            const data = {
                 meta: {
-                    type: 'memberUpdate',
-                    displayName: 'Nickname Changed',
-                    calculateType: 'guildMemberUpdate',
+                    type: "memberUpdate",
+                    displayName: "Nickname Changed",
+                    calculateType: "guildMemberUpdate",
                     color: NucleusColors.yellow,
                     emoji: "PUNISH.NICKNAME.YELLOW",
                     timestamp: new Date().getTime()
@@ -22,25 +22,25 @@
                 list: {
                     memberId: entry(after.id, `\`${after.id}\``),
                     name: entry(after.user.id, renderUser(after.user)),
-                    before: entry(before.nickname, before.nickname ? before.nickname : '*None*'),
-                    after: entry(after.nickname, after.nickname ? after.nickname : '*None*'),
+                    before: entry(before.nickname, before.nickname ? before.nickname : "*None*"),
+                    after: entry(after.nickname, after.nickname ? after.nickname : "*None*"),
                     changed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     changedBy: entry(audit.executor.id, renderUser(audit.executor))
                 },
                 hidden: {
                     guild: after.guild.id
                 }
-            }
+            };
             log(data);
         } else if (before.communicationDisabledUntilTimestamp < new Date().getTime() && after.communicationDisabledUntil > new Date().getTime()) {
-            try { await client.database.history.create(
+            await client.database.history.create(
                 "mute", after.guild.id, after.user, audit.executor, audit.reason, null, null, null
-            )} catch {}
-            let data = {
+            );
+            const data = {
                 meta: {
-                    type: 'memberMute',
-                    displayName: 'Muted',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberMute",
+                    displayName: "Muted",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.yellow,
                     emoji: "PUNISH.MUTE.YELLOW",
                     timestamp: new Date().getTime()
@@ -51,12 +51,12 @@
                     mutedUntil: entry(after.communicationDisabledUntilTimestamp, renderDelta(after.communicationDisabledUntilTimestamp)),
                     muted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     mutedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                    reason: entry(audit.reason, audit.reason ? audit.reason : '\n> *No reason provided*')
+                    reason: entry(audit.reason, audit.reason ? audit.reason : "\n> *No reason provided*")
                 },
                 hidden: {
                     guild: after.guild.id
                 }
-            }
+            };
             log(data);
             client.database.eventScheduler.schedule("naturalUnmute", after.communicationDisabledUntil,
                 {guild: after.guild.id, user: after.id, expires: after.communicationDisabledUntilTimestamp}
@@ -65,14 +65,14 @@
             after.communicationDisabledUntil === null && before.communicationDisabledUntilTimestamp !== null &&
             new Date().getTime() >= audit.createdTimestamp
         ) {
-            try { await client.database.history.create(
+            await client.database.history.create(
                 "unmute", after.guild.id, after.user, audit.executor, null, null, null, null
-            )} catch {}
-            let data = {
+            );
+            const data = {
                 meta: {
-                    type: 'memberUnmute',
-                    displayName: 'Unmuted',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberUnmute",
+                    displayName: "Unmuted",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.green,
                     emoji: "PUNISH.MUTE.GREEN",
                     timestamp: new Date().getTime()
@@ -86,9 +86,9 @@
                 hidden: {
                     guild: after.guild.id
                 }
-            }
+            };
             log(data);
             client.database.eventScheduler.cancel("naturalUnmute", {guild: after.guild.id, user: after.id, expires: before.communicationDisabledUntilTimestamp});
         }
-    } catch (e) { console.log(e) }
+    } catch (e) { console.log(e); }
 }
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index e27975b..2cb1de8 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,61 +1,59 @@
-import { callback as statsChannelUpdate } from '../reflex/statsChannelUpdate.js';
+import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildUpdate'
+export const event = "guildUpdate";
 
 export async function callback(client, before, after) {
-    try { await statsChannelUpdate(client, after.me); } catch(e) { console.log(e)}
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger
-        let auditLog = await getAuditLog(after, 'GUILD_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let list = {}
+    await statsChannelUpdate(client, after.me);
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
+    const auditLog = await getAuditLog(after, "GUILD_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const list = {};
 
-        const verificationLevels = {
-            NONE: 'Unrestricted',
-            LOW: 'Verified email',
-            MEDIUM: 'Registered (5 minutes)',
-            HIGH: 'Member (10 minutes)',
-            VERY_HIGH: 'Verified phone'
+    const verificationLevels = {
+        NONE: "Unrestricted",
+        LOW: "Verified email",
+        MEDIUM: "Registered (5 minutes)",
+        HIGH: "Member (10 minutes)",
+        VERY_HIGH: "Verified phone"
+    };
+
+    const explicitContentFilterLevels = {
+        DISABLED: "Disabled",
+        MEMBERS_WITHOUT_ROLES: "Members without roles",
+        ALL_MEMBERS: "All members"
+    };
+
+    const MFALevels = {
+        NONE: "None",
+        ELEVATED: "Enabled"
+    };
+
+    if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+    if (before.icon !== after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
+    if (before.splash !== after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
+    if (before.banner !== after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
+    if (before.owner !== after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
+    if (before.verificationLevel !== after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
+    if (before.explicitContentFilter !== after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
+    if (before.mfaLevel !== after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
+
+    if (!(Object.keys(list).length)) return;
+    list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+    list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+    const data = {
+        meta: {
+            type: "guildUpdate",
+            displayName: "Guild Edited",
+            calculateType: "guildUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.YELLOW",
+            timestamp: new Date().getTime()
+        },
+        list: list,
+        hidden: {
+            guild: after.id
         }
-
-        const explicitContentFilterLevels = {
-            DISABLED: 'Disabled',
-            MEMBERS_WITHOUT_ROLES: 'Members without roles',
-            ALL_MEMBERS: 'All members'
-        }
-
-        const MFALevels = {
-            NONE: 'None',
-            ELEVATED: 'Enabled'
-        }
-
-        if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
-        if (before.icon !== after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
-        if (before.splash !== after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
-        if (before.banner !== after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
-        if (before.owner !== after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
-        if (before.verificationLevel !== after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
-        if (before.explicitContentFilter !== after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
-        if (before.mfaLevel !== after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
-
-        if (!(Object.keys(list).length)) return;
-        list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
-        list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
-        let data = {
-            meta: {
-                type: 'guildUpdate',
-                displayName: 'Guild Edited',
-                calculateType: 'guildUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.YELLOW",
-                timestamp: new Date().getTime()
-            },
-            list: list,
-            hidden: {
-                guild: after.id
-            }
-        }
-        log(data);
-    } catch (e) {}
+    };
+    log(data);
 }
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index a4bb8c3..08fcc77 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -1,57 +1,56 @@
-import { callback as roleMenu } from "../actions/roleMenu.js"
+import { callback as roleMenu } from "../actions/roleMenu.js";
 import verify from "../reflex/verify.js";
 import create from "../actions/tickets/create.js";
 import close from "../actions/tickets/delete.js";
 import createTranscript from "../premium/createTranscript.js";
 import Fuse from "fuse.js";
-import { autocomplete as tagAutocomplete } from "../commands/tag.js"
+import { autocomplete as tagAutocomplete } from "../commands/tag.js";
 
-export const event = 'interactionCreate';
+export const event = "interactionCreate";
 
 
 function getAutocomplete(typed: string, options: string[]): object[] {
-    options = options.filter(option => option.length <= 100) // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
-    if (!typed) return options.slice(0, 25).sort().map(option => ({name: option, value: option}))
-    const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed)
-    return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}))
+    options = options.filter(option => option.length <= 100); // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
+    if (!typed) return options.slice(0, 25).sort().map(option => ({name: option, value: option}));
+    const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed);
+    return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}));
 }
 
 function generateStatsChannelAutocomplete(typed) {
-    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"]
-    let autocompletions = []
-    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
-    if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
-    else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
-    return getAutocomplete(typed, autocompletions)
+    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"];
+    const autocompletions = [];
+    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+    if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+    else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+    return getAutocomplete(typed, autocompletions);
 }
 function generateWelcomeMessageAutocomplete(typed) {
-    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"]
-    let autocompletions = []
-    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
-    if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
-    else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
-    return getAutocomplete(typed, autocompletions)
+    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"];
+    const autocompletions = [];
+    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+    if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+    else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+    return getAutocomplete(typed, autocompletions);
 }
 
 async function interactionCreate(interaction) {
     if (interaction.componentType === "BUTTON") {
         switch (interaction.customId) {
-            case "rolemenu": { return await roleMenu(interaction) }
-            case "verifybutton": { return verify(interaction) }
-            case "createticket": { return create(interaction) }
-            case "closeticket": { return close(interaction) }
-            case "createtranscript": { return createTranscript(interaction) }
+        case "rolemenu": { return await roleMenu(interaction); }
+        case "verifybutton": { return verify(interaction); }
+        case "createticket": { return create(interaction); }
+        case "closeticket": { return close(interaction); }
+        case "createtranscript": { return createTranscript(interaction); }
         }
-    } else if (interaction.componentType === "MESSAGE_COMPONENT") {
     } else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
         switch (`${interaction.commandName} ${interaction.options.getSubcommandGroup(false)} ${interaction.options.getSubcommand(false)}`) {
-            case `tag null null`: { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))) }
-            case `settings null stats`: { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))) }
-            case `settings null welcome`: { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))) }
+        case "tag null null": { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))); }
+        case "settings null stats": { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))); }
+        case "settings null welcome": { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))); }
         }
     }
 }
 
 export async function callback(client, interaction) {
-    await interactionCreate(interaction)
+    await interactionCreate(interaction);
 }
\ No newline at end of file
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 5d47bf8..1cbed02 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -1,32 +1,30 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'inviteCreate'
+import humanizeDuration from "humanize-duration";
+export const event = "inviteCreate";
 
 export async function callback(client, invite) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
-        let auditLog = await getAuditLog(invite.guild, 'INVITE_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'inviteCreate',
-                displayName: 'Invite Created',
-                calculateType: 'guildUpdate',
-                color: NucleusColors.green,
-                emoji: "INVITE.CREATE",
-                timestamp: invite.createdTimestamp
-            },
-            list: {
-                channel: entry(invite.channel.id, renderChannel(invite.channel)),
-                link: entry(invite.url, invite.url),
-                expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
-            },
-            hidden: {
-                guild: invite.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+    const auditLog = await getAuditLog(invite.guild, "INVITE_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "inviteCreate",
+            displayName: "Invite Created",
+            calculateType: "guildUpdate",
+            color: NucleusColors.green,
+            emoji: "INVITE.CREATE",
+            timestamp: invite.createdTimestamp
+        },
+        list: {
+            channel: entry(invite.channel.id, renderChannel(invite.channel)),
+            link: entry(invite.url, invite.url),
+            expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
+        },
+        hidden: {
+            guild: invite.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index acfc9dd..cbe4d4b 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -1,32 +1,30 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'inviteDelete'
+import humanizeDuration from "humanize-duration";
+export const event = "inviteDelete";
 
 export async function callback(client, invite) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
-        let auditLog = await getAuditLog(invite.guild, 'INVITE_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'inviteDelete',
-                displayName: 'Invite Deleted',
-                calculateType: 'guildUpdate',
-                color: NucleusColors.red,
-                emoji: "INVITE.DELETE",
-                timestamp: new Date().getTime()
-            },
-            list: {
-                channel: entry(invite.channel.id, renderChannel(invite.channel)),
-                link: entry(invite.url, invite.url),
-                expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
-            },
-            hidden: {
-                guild: invite.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+    const auditLog = await getAuditLog(invite.guild, "INVITE_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "inviteDelete",
+            displayName: "Invite Deleted",
+            calculateType: "guildUpdate",
+            color: NucleusColors.red,
+            emoji: "INVITE.DELETE",
+            timestamp: new Date().getTime()
+        },
+        list: {
+            channel: entry(invite.channel.id, renderChannel(invite.channel)),
+            link: entry(invite.url, invite.url),
+            expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+        },
+        hidden: {
+            guild: invite.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 109f226..34545fb 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -1,36 +1,33 @@
-import { callback as statsChannelAdd } from '../reflex/statsChannelUpdate.js';
-import { callback as welcome } from '../reflex/welcome.js';
-import log from '../utils/log.js';
-import client from '../utils/client.js';
+import { callback as statsChannelAdd } from "../reflex/statsChannelUpdate.js";
+import { callback as welcome } from "../reflex/welcome.js";
+import client from "../utils/client.js";
 
-export const event = 'guildMemberAdd'
+export const event = "guildMemberAdd";
 
 export async function callback(_, member) {
-    try { welcome(_, member); } catch {}
-    try { statsChannelAdd(_, member, ); } catch {}
-    try {
-        const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
-        try { await client.database.history.create("join", member.guild.id, member.user, null, null) } catch {}
-        let data = {
-            meta: {
-                type: 'memberJoin',
-                displayName: 'Member Joined',
-                calculateType: 'guildMemberUpdate',
-                color: NucleusColors.green,
-                emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
-                timestamp: member.joinedTimestamp
-            },
-            list: {
-                memberId: entry(member.id, `\`${member.id}\``),
-                name: entry(member.id, renderUser(member.user)),
-                joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
-                accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                serverMemberCount: member.guild.memberCount,
-            },
-            hidden: {
-                guild: member.guild.id
-            }
+    welcome(_, member);
+    statsChannelAdd(_, member );
+    const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+    await client.database.history.create("join", member.guild.id, member.user, null, null);
+    const data = {
+        meta: {
+            type: "memberJoin",
+            displayName: "Member Joined",
+            calculateType: "guildMemberUpdate",
+            color: NucleusColors.green,
+            emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
+            timestamp: member.joinedTimestamp
+        },
+        list: {
+            memberId: entry(member.id, `\`${member.id}\``),
+            name: entry(member.id, renderUser(member.user)),
+            joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+            accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+            serverMemberCount: member.guild.memberCount
+        },
+        hidden: {
+            guild: member.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 5dff86f..842a48b 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,72 +1,70 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildMemberRemove'
+export const event = "guildMemberRemove";
 
 export async function callback(client, member) {
-    try { purgeByUser(member.id, member.guild); } catch {}
-    try { await statsChannelRemove(client, member); } catch {}
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
-        let auditLog = await getAuditLog(member.guild, 'MEMBER_KICK');
-        let audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
-        let type = "leave"
-        if (audit) {
-            if (audit.executor.id === client.user.id) return
-            if (audit.createdAt - 100 >= new Date().getTime()) {
-                type = "kick"
-            }
+    purgeByUser(member.id, member.guild);
+    await statsChannelRemove(client, member);
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+    const auditLog = await getAuditLog(member.guild, "MEMBER_KICK");
+    const audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
+    let type = "leave";
+    if (audit) {
+        if (audit.executor.id === client.user.id) return;
+        if (audit.createdAt - 100 >= new Date().getTime()) {
+            type = "kick";
         }
-        let data
-        if (type === "kick") {
-            try { await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason) } catch {}
-            data = {
-                meta: {
-                    type: 'memberKick',
-                    displayName: 'Member Kicked',
-                    calculateType: 'guildMemberPunish',
-                    color: NucleusColors.red,
-                    emoji: "PUNISH.KICK.RED",
-                    timestamp: new Date().getTime()
-                },
-                list: {
-                    memberId: entry(member.id, `\`${member.id}\``),
-                    name: entry(member.id, renderUser(member.user)),
-                    joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
-                    kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                    kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                    reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
-                    accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                    serverMemberCount: member.guild.memberCount,
-                },
-                hidden: {
-                    guild: member.guild.id
-                }
+    }
+    let data;
+    if (type === "kick") {
+        await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
+        data = {
+            meta: {
+                type: "memberKick",
+                displayName: "Member Kicked",
+                calculateType: "guildMemberPunish",
+                color: NucleusColors.red,
+                emoji: "PUNISH.KICK.RED",
+                timestamp: new Date().getTime()
+            },
+            list: {
+                memberId: entry(member.id, `\`${member.id}\``),
+                name: entry(member.id, renderUser(member.user)),
+                joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+                kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+                kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
+                reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+                accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+                serverMemberCount: member.guild.memberCount
+            },
+            hidden: {
+                guild: member.guild.id
             }
-        } else {
-            try { await client.database.history.create("leave", member.guild.id, member.user, null, null) } catch {}
-            data = {
-                meta: {
-                    type: 'memberLeave',
-                    displayName: 'Member Left',
-                    calculateType: 'guildMemberUpdate',
-                    color: NucleusColors.red,
-                    emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
-                    timestamp: new Date().getTime()
-                },
-                list: {
-                    memberId: entry(member.id, `\`${member.id}\``),
-                    name: entry(member.id, renderUser(member.user)),
-                    joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
-                    left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                    accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                    serverMemberCount: member.guild.memberCount,
-                },
-                hidden: {
-                    guild: member.guild.id
-                }
+        };
+    } else {
+        await client.database.history.create("leave", member.guild.id, member.user, null, null);
+        data = {
+            meta: {
+                type: "memberLeave",
+                displayName: "Member Left",
+                calculateType: "guildMemberUpdate",
+                color: NucleusColors.red,
+                emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
+                timestamp: new Date().getTime()
+            },
+            list: {
+                memberId: entry(member.id, `\`${member.id}\``),
+                name: entry(member.id, renderUser(member.user)),
+                joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
+                left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+                accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+                serverMemberCount: member.guild.memberCount
+            },
+            hidden: {
+                guild: member.guild.id
             }
-        }
-        log(data);
-    } catch (e) { console.log(e) }
+        };
+    }
+    log(data);
 }
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index cbb1fa2..bbb6a32 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,28 +1,33 @@
-import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../reflex/scanners.js'
-import logAttachment from '../premium/attachmentLogs.js'
-import createLogException from '../utils/createLogException.js'
-import getEmojiByName from '../utils/getEmojiByName.js';
-import client from '../utils/client.js';
-import {callback as a} from '../reflex/statsChannelUpdate.js'
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import { HaikuClient } from "jshaiku";
+import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js";
+import logAttachment from "../premium/attachmentLogs.js";
+import createLogException from "../utils/createLogException.js";
+import getEmojiByName from "../utils/getEmojiByName.js";
+import client from "../utils/client.js";
+import {callback as a} from "../reflex/statsChannelUpdate.js";
+import type { Message } from "discord.js";
 
-export const event = 'messageCreate'
+export const event = "messageCreate";
 
-export async function callback(_, message) {
+export async function callback(_client: HaikuClient, message: Message) {
     if(!message) return;
-    if (message.author.bot) return
-    if (message.channel.type === 'dm') return
-    try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e)}
+    if(!message.guild) return;
+    if (message.author.bot) return;
+    if (message.channel.type === "DM") return;
+    try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e);}
 
-    const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger
+    const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
 
-    let fileNames = await logAttachment(message);
+    const fileNames = await logAttachment(message);
 
-    let content = message.content.toLowerCase() || ''
-    let config = await client.memory.readGuildInfo(message.guild.id);
-    const filter = getEmojiByName("ICONS.FILTER")
-    let attachmentJump = ""
-    if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})` }
-    let list = {
+    const content = message.content.toLowerCase() || "";
+    const config = await client.memory.readGuildInfo(message.guild.id);
+    const filter = getEmojiByName("ICONS.FILTER");
+    let attachmentJump = "";
+    if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`; }
+    const list = {
         messageId: entry(message.id, `\`${message.id}\``),
         sentBy: entry(message.author.id, renderUser(message.author)),
         sentIn: entry(message.channel.id, renderChannel(message.channel)),
@@ -33,116 +38,115 @@
             message.reference ? message.reference.messageId : null,
             message.reference ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
         )
-    }
+    };
 
     if (config.filters.invite.enabled) {
-        if (!config.filters.invite.allowed.users.includes(message.author.id) ||
-            !config.filters.invite.allowed.channels.includes(message.channel.id) ||
-            !message.author.roles.cache.some(role => config.filters.invite.allowed.roles.includes(role.id))
-        ) {
+        if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
             if ((/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content))) {
-                createLogException(message.guild.id, message.channel.id, message.id)
+                createLogException(message.guild.id, message.channel.id, message.id);
                 message.delete();
-                let data = {
+                const data = {
                     meta: {
-                        type: 'messageDelete',
-                        displayName: 'Message Deleted (Automated, Contained Invite)',
-                        calculateType: 'autoModeratorDeleted',
+                        type: "messageDelete",
+                        displayName: "Message Deleted (Automated, Contained Invite)",
+                        calculateType: "autoModeratorDeleted",
                         color: NucleusColors.red,
-                        emoji: 'MESSAGE.DELETE',
+                        emoji: "MESSAGE.DELETE",
                         timestamp: new Date().getTime()
                     },
                     separate: {
-                        start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                        start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                     },
                     list: list,
                     hidden: {
                         guild: message.channel.guild.id
                     }
-                }
+                };
                 return log(data);
             }
         }
     }
 
     if (fileNames.files.length > 0) {
-        for (let element of fileNames.files) {
+        for (const element of fileNames.files) {
             if(!message) return;
-            let url = element.url ? element.url : element.local
+            const url = element.url ? element.url : element.local;
             if (url !== undefined) {
                 if(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)) {
-                    if (config.filters.images.NSFW && !message.channel.nsfw) {
+                    if (config.filters.images.NSFW && !(
+                        message.channel.type === "GUILD_PUBLIC_THREAD" ? false : message.channel.nsfw
+                    )) {
                         if (await NSFWCheck(url)) {
-                            createLogException(message.guild.id, message.channel.id, message.id)
-                            await message.delete()
-                            let data = {
+                            createLogException(message.guild.id, message.channel.id, message.id);
+                            await message.delete();
+                            const data = {
                                 meta: {
-                                    type: 'messageDelete',
-                                    displayName: 'Message Deleted',
-                                    calculateType: 'autoModeratorDeleted',
+                                    type: "messageDelete",
+                                    displayName: "Message Deleted",
+                                    calculateType: "autoModeratorDeleted",
                                     color: NucleusColors.red,
-                                    emoji: 'MESSAGE.DELETE',
+                                    emoji: "MESSAGE.DELETE",
                                     timestamp: new Date().getTime()
                                 },
                                 separate: {
-                                    start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                    start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                                 },
                                 list: list,
                                 hidden: {
                                     guild: message.channel.guild.id
                                 }
-                            }
+                            };
                             return log(data);
                         }
                     }
                     if (config.filters.wordFilter.enabled) {
-                        let text = await TestImage(url)
-                        let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+                        const text = await TestImage(url);
+                        const check = TestString(text ?? "", config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict);
                         if(check !== null) {
-                            createLogException(message.guild.id, message.channel.id, message.id)
-                            await message.delete()
-                            let data = {
+                            createLogException(message.guild.id, message.channel.id, message.id);
+                            await message.delete();
+                            const data = {
                                 meta: {
-                                    type: 'messageDelete',
-                                    displayName: 'Message Deleted',
-                                    calculateType: 'autoModeratorDeleted',
+                                    type: "messageDelete",
+                                    displayName: "Message Deleted",
+                                    calculateType: "autoModeratorDeleted",
                                     color: NucleusColors.red,
-                                    emoji: 'MESSAGE.DELETE',
+                                    emoji: "MESSAGE.DELETE",
                                     timestamp: new Date().getTime()
                                 },
                                 separate: {
-                                    start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                    start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                                 },
                                 list: list,
                                 hidden: {
                                     guild: message.channel.guild.id
                                 }
-                            }
+                            };
                             return log(data);
                         }
                     }
                     if (config.filters.images.size) {
                         if(url.match(/\.+(webp|png|jpg)$/gi)) {
                             if(!await SizeCheck(element)) {
-                                createLogException(message.guild.id, message.channel.id, message.id)
-                                await message.delete()
-                                let data = {
+                                createLogException(message.guild.id, message.channel.id, message.id);
+                                await message.delete();
+                                const data = {
                                     meta: {
-                                        type: 'messageDelete',
-                                        displayName: 'Message Deleted',
-                                        calculateType: 'autoModeratorDeleted',
+                                        type: "messageDelete",
+                                        displayName: "Message Deleted",
+                                        calculateType: "autoModeratorDeleted",
                                         color: NucleusColors.red,
-                                        emoji: 'MESSAGE.DELETE',
+                                        emoji: "MESSAGE.DELETE",
                                         timestamp: new Date().getTime()
                                     },
                                     separate: {
-                                        start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                        start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                                     },
                                     list: list,
                                     hidden: {
                                         guild: message.channel.guild.id
                                     }
-                                }
+                                };
                                 return log(data);
                             }
                         }
@@ -150,150 +154,150 @@
                 }
                 if (config.filters.malware) {
                     if (!MalwareCheck(url)) {
-                        createLogException(message.guild.id, message.channel.id, message.id)
-                        await message.delete()
-                        let data = {
+                        createLogException(message.guild.id, message.channel.id, message.id);
+                        await message.delete();
+                        const data = {
                             meta: {
-                                type: 'messageDelete',
-                                displayName: 'Message Deleted',
-                                calculateType: 'autoModeratorDeleted',
+                                type: "messageDelete",
+                                displayName: "Message Deleted",
+                                calculateType: "autoModeratorDeleted",
                                 color: NucleusColors.red,
-                                emoji: 'MESSAGE.DELETE',
+                                emoji: "MESSAGE.DELETE",
                                 timestamp: new Date().getTime()
                             },
                             separate: {
-                                start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                             },
                             list: list,
                             hidden: {
                                 guild: message.channel.guild.id
                             }
-                        }
+                        };
                         return log(data);
                     }
                 }
             }
-        };
+        }
     }
     if(!message) return;
 
-    let linkDetectionTypes = await LinkCheck(message)
+    const linkDetectionTypes = await LinkCheck(message);
     if (linkDetectionTypes.length > 0) {
-        createLogException(message.guild.id, message.channel.id, message.id)
-        await message.delete()
-        let data = {
+        createLogException(message.guild.id, message.channel.id, message.id);
+        await message.delete();
+        const data = {
             meta: {
-                type: 'messageDelete',
-                displayName: `Message Deleted`,
-                calculateType: 'autoModeratorDeleted',
+                type: "messageDelete",
+                displayName: "Message Deleted",
+                calculateType: "autoModeratorDeleted",
                 color: NucleusColors.red,
-                emoji: 'MESSAGE.DELETE',
+                emoji: "MESSAGE.DELETE",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: filter + ` Link filtered as ${linkDetectionTypes[0].toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                start: filter + ` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
             },
             list: list,
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         return log(data);
     }
 
     if (config.filters.wordFilter.enabled) {
-        let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+        const check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict);
         if(check !== null) {
-            createLogException(message.guild.id, message.channel.id, message.id)
-            await message.delete()
-            let data = {
+            createLogException(message.guild.id, message.channel.id, message.id);
+            await message.delete();
+            const data = {
                 meta: {
-                    type: 'messageDelete',
-                    displayName: 'Message Deleted',
-                    calculateType: 'autoModeratorDeleted',
+                    type: "messageDelete",
+                    displayName: "Message Deleted",
+                    calculateType: "autoModeratorDeleted",
                     color: NucleusColors.red,
-                    emoji: 'MESSAGE.DELETE',
+                    emoji: "MESSAGE.DELETE",
                     timestamp: new Date().getTime()
                 },
                 separate: {
-                    start: filter + ` Message contained filtered word\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                    start: filter + " Message contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                 },
                 list: list,
                 hidden: {
                     guild: message.channel.guild.id
                 }
-            }
+            };
             return log(data);
         }
     }
 
     if (config.filters.pings.everyone && message.mentions.everyone) {
-        let data = {
+        const data = {
             meta: {
-                type: 'everyonePing',
-                displayName: 'Everyone Pinged',
-                calculateType: 'messageMassPing',
+                type: "everyonePing",
+                displayName: "Everyone Pinged",
+                calculateType: "messageMassPing",
                 color: NucleusColors.yellow,
-                emoji: 'MESSAGE.PING.EVERYONE',
+                emoji: "MESSAGE.PING.EVERYONE",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
             },
             list: list,
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         return log(data);
     }
     if (config.filters.pings.roles) {
-        for(let role of message.mentions.roles) {
+        for(const roleId in message.mentions.roles) {
             if(!message) return;
-            if (!config.filters.pings.allowed.roles.includes(role.id)) {
-                createLogException(message.guild.id, message.channel.id, message.id)
-                await message.delete()
-                let data = {
+            if (!config.filters.pings.allowed.roles.includes(roleId)) {
+                createLogException(message.guild.id, message.channel.id, message.id);
+                await message.delete();
+                const data = {
                     meta: {
-                        type: 'rolePing',
-                        displayName: 'Role Pinged',
-                        calculateType: 'messageMassPing',
+                        type: "rolePing",
+                        displayName: "Role Pinged",
+                        calculateType: "messageMassPing",
                         color: NucleusColors.yellow,
-                        emoji: 'MESSAGE.PING.ROLE',
+                        emoji: "MESSAGE.PING.ROLE",
                         timestamp: new Date().getTime()
                     },
                     separate: {
-                        start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                        start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
                     },
                     list: list,
                     hidden: {
                         guild: message.channel.guild.id
                     }
-                }
+                };
                 return log(data);
             }
         }
     }
     if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
-        createLogException(message.guild.id, message.channel.id, message.id)
-        await message.delete()
-        let data = {
+        createLogException(message.guild.id, message.channel.id, message.id);
+        await message.delete();
+        const data = {
             meta: {
-                type: 'massPing',
-                displayName: `Mass Ping`,
-                calculateType: 'messageMassPing',
+                type: "massPing",
+                displayName: "Mass Ping",
+                calculateType: "messageMassPing",
                 color: NucleusColors.yellow,
-                emoji: 'MESSAGE.PING.MASS',
+                emoji: "MESSAGE.PING.MASS",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
             },
             list: list,
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         return log(data);
     }
 }
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index b139297..473fa52 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -1,34 +1,34 @@
-export const event = 'messageDelete'
+export const event = "messageDelete";
 
 export async function callback(client, message) {
     try {
         if (message.author.id === client.user.id) return;
         if (client.noLog.includes(`${message.guild.id}/${message.channel.id}/${message.id}`)) return;
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
-        let auditLog = await getAuditLog(message.guild, 'MEMBER_BAN_ADD')
-        let audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
+        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger;
+        const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
+        const audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
         if (audit) {
             if (audit.createdAt - 100 < new Date().getTime()) return;
         }
-        message.reference = message.reference || {}
-        let content = message.cleanContent
-        content.replace(`\``, `\\\``)
-        if (content.length > 256) content = content.substring(0, 253) + '...'
-        let attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []).length
-        let attachmentJump = ""
-        let config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
-        if (config) { attachmentJump = ` [[View attachments]](${config})` }
-        let data = {
+        message.reference = message.reference || {};
+        let content = message.cleanContent;
+        content.replace("`", "\\`");
+        if (content.length > 256) content = content.substring(0, 253) + "...";
+        const attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi) ?? []).length;
+        let attachmentJump = "";
+        const config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
+        if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+        const data = {
             meta: {
-                type: 'messageDelete',
-                displayName: 'Message Deleted',
-                calculateType: 'messageDelete',
+                type: "messageDelete",
+                displayName: "Message Deleted",
+                calculateType: "messageDelete",
                 color: NucleusColors.red,
-                emoji: 'MESSAGE.DELETE',
+                emoji: "MESSAGE.DELETE",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
             },
             list: {
                 messageId: entry(message.id, `\`${message.id}\``),
@@ -45,7 +45,7 @@
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         log(data);
-    } catch(e) { console.log(e) }
+    } catch(e) { console.log(e); }
 }
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 9e0e521..148cdb7 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -1,85 +1,83 @@
-export const event = 'messageUpdate'
+export const event = "messageUpdate";
 
 export async function callback(client, oldMessage, newMessage) {
-    try {
-        if (newMessage.author.id === client.user.id) return;
-        const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
-        newMessage.reference = newMessage.reference || {}
-        let newContent = newMessage.cleanContent.replaceAll("`", "‘")
-        let oldContent = oldMessage.cleanContent.replaceAll("`", "‘")
-        let attachmentJump = "";
-        let config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[newMessage.channel.id + newMessage.id];
-        if (config) { attachmentJump = ` [[View attachments]](${config})` }
-        if (newContent === oldContent) {
-            if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
-                let data = {
-                    meta: {
-                        type: 'messageAnnounce',
-                        displayName: 'Message Published',
-                        calculateType: 'messageAnnounce',
-                        color: NucleusColors.yellow,
-                        emoji: 'MESSAGE.CREATE',
-                        timestamp: newMessage.editedTimestamp
-                    },
-                    separate: {
-                        end: `[[Jump to message]](${newMessage.url})`
-                    },
-                    list: {
-                        messageId: entry(newMessage.id, `\`${newMessage.id}\``),
-                        sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
-                        sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
-                        sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
-                        published: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
-                        mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
-                        attachments: entry(
-                            renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
-                            renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
-                        )
-                    },
-                    hidden: {
-                        guild: newMessage.channel.guild.id
-                    }
+    if (newMessage.author.id === client.user.id) return;
+    const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger;
+    newMessage.reference = newMessage.reference || {};
+    let newContent = newMessage.cleanContent.replaceAll("`", "‘");
+    let oldContent = oldMessage.cleanContent.replaceAll("`", "‘");
+    let attachmentJump = "";
+    const config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[newMessage.channel.id + newMessage.id];
+    if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+    if (newContent === oldContent) {
+        if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
+            const data = {
+                meta: {
+                    type: "messageAnnounce",
+                    displayName: "Message Published",
+                    calculateType: "messageAnnounce",
+                    color: NucleusColors.yellow,
+                    emoji: "MESSAGE.CREATE",
+                    timestamp: newMessage.editedTimestamp
+                },
+                separate: {
+                    end: `[[Jump to message]](${newMessage.url})`
+                },
+                list: {
+                    messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+                    sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+                    sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+                    sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+                    published: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+                    mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+                    attachments: entry(
+                        renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+                        renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+                    )
+                },
+                hidden: {
+                    guild: newMessage.channel.guild.id
                 }
-                return log(data);
-            }
-        };
-        if (!newMessage.editedTimestamp) { return }
-        if (newContent.length > 256) newContent = newContent.substring(0, 253) + '...'
-        if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + '...'
-        let data = {
-            meta: {
-                type: 'messageUpdate',
-                displayName: 'Message Edited',
-                calculateType: 'messageUpdate',
-                color: NucleusColors.yellow,
-                emoji: 'MESSAGE.EDIT',
-                timestamp: newMessage.editedTimestamp
-            },
-            separate: {
-                start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : '**Before:** *Message had no content*\n') +
-                    (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : '**After:** *Message had no content*'),
-                end: `[[Jump to message]](${newMessage.url})`
-            },
-            list: {
-                messageId: entry(newMessage.id, `\`${newMessage.id}\``),
-                sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
-                sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
-                sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
-                edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
-                mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
-                attachments: entry(
-                    renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
-                    renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
-                ),
-                repliedTo: entry(
-                    newMessage.reference.messageId || null,
-                    newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
-                )
-            },
-            hidden: {
-                guild: newMessage.channel.guild.id
-            }
+            };
+            return log(data);
         }
-        log(data);
-    } catch {}
-}
+    }
+    if (!newMessage.editedTimestamp) { return; }
+    if (newContent.length > 256) newContent = newContent.substring(0, 253) + "...";
+    if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + "...";
+    const data = {
+        meta: {
+            type: "messageUpdate",
+            displayName: "Message Edited",
+            calculateType: "messageUpdate",
+            color: NucleusColors.yellow,
+            emoji: "MESSAGE.EDIT",
+            timestamp: newMessage.editedTimestamp
+        },
+        separate: {
+            start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : "**Before:** *Message had no content*\n") +
+                (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : "**After:** *Message had no content*"),
+            end: `[[Jump to message]](${newMessage.url})`
+        },
+        list: {
+            messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+            sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+            sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+            sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+            edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+            mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+            attachments: entry(
+                renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+                renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+            ),
+            repliedTo: entry(
+                newMessage.reference.messageId || null,
+                newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
+            )
+        },
+        hidden: {
+            guild: newMessage.channel.guild.id
+        }
+    };
+    log(data);
+}
\ No newline at end of file
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 2f159ac..a717242 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,31 +1,29 @@
-export const event = 'roleCreate'
+export const event = "roleCreate";
 
 export async function callback(client, role) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
-        if (role.managed) return;
-        let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'roleCreate',
-                displayName: 'Role Created',
-                calculateType: 'guildRoleUpdate',
-                color: NucleusColors.green,
-                emoji: "GUILD.ROLES.CREATE",
-                timestamp: role.createdTimestamp
-            },
-            list: {
-                roleId: entry(role.id, `\`${role.id}\``),
-                role: entry(role.name, renderRole(role)),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
-            },
-            hidden: {
-                guild: role.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger;
+    if (role.managed) return;
+    const auditLog = await getAuditLog(role.guild, "ROLE_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "roleCreate",
+            displayName: "Role Created",
+            calculateType: "guildRoleUpdate",
+            color: NucleusColors.green,
+            emoji: "GUILD.ROLES.CREATE",
+            timestamp: role.createdTimestamp
+        },
+        list: {
+            roleId: entry(role.id, `\`${role.id}\``),
+            role: entry(role.name, renderRole(role)),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
+        },
+        hidden: {
+            guild: role.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 3b43a55..ad74584 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -1,38 +1,36 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'roleDelete'
+export const event = "roleDelete";
 
 export async function callback(client, role) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
-        if (role.managed) return;
-        let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'roleDelete',
-                displayName: 'Role Deleted',
-                calculateType: 'guildRoleUpdate',
-                color: NucleusColors.red,
-                emoji: "GUILD.ROLES.DELETE",
-                timestamp: audit.createdTimestamp,
-            },
-            list: {
-                roleId: entry(role.id, `\`${role.id}\``),
-                role: entry(role.name, role.name),
-                color: entry(role.hexColor, `\`${role.hexColor}\``),
-                showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
-                mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
-                members: entry(role.members.size, `${role.members.size}`),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
-                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
-            },
-            hidden: {
-                guild: role.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger;
+    if (role.managed) return;
+    const auditLog = await getAuditLog(role.guild, "ROLE_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "roleDelete",
+            displayName: "Role Deleted",
+            calculateType: "guildRoleUpdate",
+            color: NucleusColors.red,
+            emoji: "GUILD.ROLES.DELETE",
+            timestamp: audit.createdTimestamp
+        },
+        list: {
+            roleId: entry(role.id, `\`${role.id}\``),
+            role: entry(role.name, role.name),
+            color: entry(role.hexColor, `\`${role.hexColor}\``),
+            showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+            mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+            members: entry(role.members.size, `${role.members.size}`),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
+            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+        },
+        hidden: {
+            guild: role.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 7c03c97..c51a9b3 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -1,49 +1,47 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'roleUpdate';
+export const event = "roleUpdate";
 
 export async function callback(client, or, nr) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
 
-        let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
-        let audit = auditLog.entries.first();
-        if (audit.executor.id === client.user.id) return;
+    const auditLog = await getAuditLog(nr.guild, "ROLE_UPDATE");
+    const audit = auditLog.entries.first();
+    if (audit.executor.id === client.user.id) return;
 
-        let changes = {
-            roleId: entry(nr.id, `\`${nr.id}\``),
-            role: entry(nr.id, renderRole(nr)),
-            edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user)),
+    const changes = {
+        roleId: entry(nr.id, `\`${nr.id}\``),
+        role: entry(nr.id, renderRole(nr)),
+        edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+        editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user))
+    };
+    const mentionable = ["", ""];
+    const hoist = ["", ""];
+    mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+    mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+    hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+    hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+    if (or.name !== nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
+    if (or.position !== nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
+    if (or.hoist !== nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
+    if (or.mentionable !== nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+    if (or.hexColor !== nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
+
+    if (Object.keys(changes).length === 4) return;
+
+    const data = {
+        meta:{
+            type: "roleUpdate",
+            displayName: "Role Edited",
+            calculateType: "guildRoleUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.ROLES.EDIT",
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: nr.guild.id
         }
-        let mentionable = ["", ""]
-        let hoist = ["", ""]
-        mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-        mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-        hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-        hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-        if (or.name !== nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
-        if (or.position !== nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
-        if (or.hoist !== nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
-        if (or.mentionable !== nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
-        if (or.hexColor !== nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
-
-        if (Object.keys(changes).length === 4) return
-
-        let data = {
-            meta:{
-                type: 'roleUpdate',
-                displayName: 'Role Edited',
-                calculateType: 'guildRoleUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.ROLES.EDIT",
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: nr.guild.id
-            }
-        } // TODO: show perms changed (webpage)
-        log(data);
-    } catch {}
+    }; // TODO: show perms changed (webpage)
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 669de32..43f2e9c 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,30 +1,28 @@
-export const event = 'stickerCreate'
+export const event = "stickerCreate";
 
 export async function callback(client, emoji) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
-        let auditLog = await getAuditLog(emoji.guild, 'STICKER_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'stickerCreate',
-                displayName: 'Sticker Created',
-                calculateType: 'stickerUpdate',
-                color: NucleusColors.green,
-                emoji: "GUILD.EMOJI.CREATE",
-                timestamp: emoji.createdTimestamp
-            },
-            list: {
-                stickerId: entry(emoji.id, `\`${emoji.id}\``),
-                emoji: entry(emoji.name, `\`:${emoji.name}:\``),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "STICKER_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "stickerCreate",
+            displayName: "Sticker Created",
+            calculateType: "stickerUpdate",
+            color: NucleusColors.green,
+            emoji: "GUILD.EMOJI.CREATE",
+            timestamp: emoji.createdTimestamp
+        },
+        list: {
+            stickerId: entry(emoji.id, `\`${emoji.id}\``),
+            emoji: entry(emoji.name, `\`:${emoji.name}:\``),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 0431bda..297e6b0 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,31 +1,29 @@
-export const event = 'stickerDelete'
+export const event = "stickerDelete";
 
 export async function callback(client, emoji) {
-    try{
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
-        let auditLog = await getAuditLog(emoji.guild, 'STICKER_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'stickerDelete',
-                displayName: 'Sticker Deleted',
-                calculateType: 'stickerUpdate',
-                color: NucleusColors.red,
-                emoji: "GUILD.EMOJI.DELETE",
-                timestamp: audit.createdTimestamp,
-            },
-            list: {
-                stickerId:entry(emoji.id, `\`${emoji.id}\``),
-                sticker: entry(emoji.name, `\`${emoji.name}\``),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
-                deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "STICKER_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "stickerDelete",
+            displayName: "Sticker Deleted",
+            calculateType: "stickerUpdate",
+            color: NucleusColors.red,
+            emoji: "GUILD.EMOJI.DELETE",
+            timestamp: audit.createdTimestamp
+        },
+        list: {
+            stickerId:entry(emoji.id, `\`${emoji.id}\``),
+            sticker: entry(emoji.name, `\`${emoji.name}\``),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+            deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 363e072..1bb0fe6 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,34 +1,32 @@
-export const event = 'stickerUpdate';
+export const event = "stickerUpdate";
 
 export async function callback(client, oe, ne) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
 
-        if (oe.name === ne.name) return
-        let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
-        let audit = auditLog.entries.first();
-        if (audit.executor.id === client.user.id) return;
+    if (oe.name === ne.name) return;
+    const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
+    const audit = auditLog.entries.first();
+    if (audit.executor.id === client.user.id) return;
 
-        let changes = {
-            stickerId:entry(ne.id, `\`${ne.id}\``),
-            edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
-            editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
-            name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+    const changes = {
+        stickerId:entry(ne.id, `\`${ne.id}\``),
+        edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+        editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+        name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
+    };
+    const data = {
+        meta:{
+            type: "stickerUpdate",
+            displayName: "Sticker Edited",
+            calculateType: "stickerUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.EMOJI.EDIT",
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: ne.guild.id
         }
-        let data = {
-            meta:{
-                type: 'stickerUpdate',
-                displayName: 'Sticker Edited',
-                calculateType: 'stickerUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.EMOJI.EDIT",
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: ne.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index ef7246d..d6b9e93 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -1,34 +1,32 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadCreate'
+import humanizeDuration from "humanize-duration";
+export const event = "threadCreate";
 
 export async function callback(client, thread) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
-        let auditLog = await getAuditLog(thread.guild, 'THREAD_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let data = {
-            meta: {
-                type: 'channelCreate',
-                displayName: 'Thread Created',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.green,
-                emoji: "CHANNEL.TEXT.CREATE",
-                timestamp: thread.createdTimestamp
-            },
-            list: {
-                threadId:entry(thread.id, `\`${thread.id}\``),
-                name: entry(thread.name, renderChannel(thread)),
-                parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
-                category: entry(thread.parent.parent ? thread.parent.parent.name : 'None', thread.parent.parent ? renderChannel(thread.parent.parent) : 'None'),
-                autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
-            },
-            hidden: {
-                guild: thread.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+    const auditLog = await getAuditLog(thread.guild, "THREAD_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "channelCreate",
+            displayName: "Thread Created",
+            calculateType: "channelUpdate",
+            color: NucleusColors.green,
+            emoji: "CHANNEL.TEXT.CREATE",
+            timestamp: thread.createdTimestamp
+        },
+        list: {
+            threadId:entry(thread.id, `\`${thread.id}\``),
+            name: entry(thread.name, renderChannel(thread)),
+            parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
+            category: entry(thread.parent.parent ? thread.parent.parent.name : "None", thread.parent.parent ? renderChannel(thread.parent.parent) : "None"),
+            autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
+        },
+        hidden: {
+            guild: thread.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 9574826..f3a59e7 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -1,17 +1,16 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadDelete'
+import humanizeDuration from "humanize-duration";
+export const event = "threadDelete";
 
 export async function callback(client, thread) {
-    try {
-    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
-    let auditLog = await getAuditLog(thread.guild, 'THREAD_UPDATE');
-    let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+    const auditLog = await getAuditLog(thread.guild, "THREAD_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
     if (audit.executor.id === client.user.id) return;
-    let data = {
+    const data = {
         meta: {
-            type: 'channelDelete',
-            displayName: 'Thread Deleted',
-            calculateType: 'channelUpdate',
+            type: "channelDelete",
+            displayName: "Thread Deleted",
+            calculateType: "channelUpdate",
             color: NucleusColors.red,
             emoji: "CHANNEL.TEXT.DELETE",
             timestamp: new Date().getTime()
@@ -20,7 +19,7 @@
             threadId:entry(thread.id, `\`${thread.id}\``),
             name: entry(thread.name, thread.name),
             parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
-            category: entry(thread.parent.parent ? thread.parent.parent.name : 'None', thread.parent.parent ? renderChannel(thread.parent.parent) : 'None'),
+            category: entry(thread.parent.parent ? thread.parent.parent.name : "None", thread.parent.parent ? renderChannel(thread.parent.parent) : "None"),
             autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
             membersInThread: entry(thread.memberCount, thread.memberCount),
             deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
@@ -30,7 +29,6 @@
         hidden: {
             guild: thread.guild.id
         }
-    }
+    };
     log(data);
-    } catch {}
 }
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 8550ffe..89a721c 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -1,43 +1,41 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadUpdate'
+import humanizeDuration from "humanize-duration";
+export const event = "threadUpdate";
 
 export async function callback(client, before, after) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger
-        let auditLog = await getAuditLog(after.guild, 'THREAD_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
-        if (audit.executor.id === client.user.id) return;
-        let list = {
-            threadId:entry(after.id, `\`${after.id}\``),
-            thread: entry(after.name, renderChannel(after)),
-            parentChannel: entry(after.parentId, renderChannel(after.parent)),
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger;
+    const auditLog = await getAuditLog(after.guild, "THREAD_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const list = {
+        threadId:entry(after.id, `\`${after.id}\``),
+        thread: entry(after.name, renderChannel(after)),
+        parentChannel: entry(after.parentId, renderChannel(after.parent))
+    };
+    if (before.name !== after.name) {
+        list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+    }
+    if (before.autoArchiveDuration !== after.autoArchiveDuration) {
+        list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
+    }
+    if (before.rateLimitPerUser !== after.rateLimitPerUser) {
+        list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
+    }
+    if (!(Object.keys(list).length - 3)) return;
+    list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+    list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+    const data = {
+        meta: {
+            type: "channelUpdate",
+            displayName: "Thread Edited",
+            calculateType: "channelUpdate",
+            color: NucleusColors.yellow,
+            emoji: "CHANNEL.TEXT.EDIT",
+            timestamp: new Date().getTime()
+        },
+        list: list,
+        hidden: {
+            guild: after.guild.id
         }
-        if (before.name !== after.name) {
-            list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
-        }
-        if (before.autoArchiveDuration !== after.autoArchiveDuration) {
-            list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
-        }
-        if (before.rateLimitPerUser !== after.rateLimitPerUser) {
-            list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
-        }
-        if (!(Object.keys(list).length - 3)) return;
-        list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
-        list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
-        let data = {
-            meta: {
-                type: 'channelUpdate',
-                displayName: 'Thread Edited',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.yellow,
-                emoji: "CHANNEL.TEXT.EDIT",
-                timestamp: new Date().getTime()
-            },
-            list: list,
-            hidden: {
-                guild: after.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 28768b2..a11fa63 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -1,35 +1,38 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'webhookUpdate'
+import type Discord from "discord.js";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { HaikuClient } from "jshaiku";
+export const event = "webhookUpdate";
 
-export async function callback(client, channel) {
+export async function callback(client: HaikuClient, channel: Discord.GuildChannel) {
     try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
-        let auditLogCreate = getAuditLog(channel.guild, 'WEBHOOK_CREATE');
-        let auditLogUpdate = getAuditLog(channel.guild, 'WEBHOOK_UPDATE');
-        let auditLogDelete = getAuditLog(channel.guild, 'WEBHOOK_DELETE');
+        const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+        let auditLogCreate = getAuditLog(channel.guild, "WEBHOOK_CREATE");
+        let auditLogUpdate = getAuditLog(channel.guild, "WEBHOOK_UPDATE");
+        let auditLogDelete = getAuditLog(channel.guild, "WEBHOOK_DELETE");
         [auditLogCreate, auditLogUpdate, auditLogDelete] = await Promise.all([auditLogCreate, auditLogUpdate, auditLogDelete]);
-        let auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
-        let auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
-        let auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
+        const auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
+        const auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
+        const auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
         if (!auditCreate && !auditUpdate && !auditDelete) return;
         let audit = auditCreate;
         let action = "Create";
-        let list = {} as any;
+        let list = {} as {created: { value: string, displayValue: string }, updated: { value: string, displayValue: string }, deleted: { value: string, displayValue: string }};
         if (auditUpdate && auditUpdate.createdTimestamp > audit.createdTimestamp) {
-            let {before, after} = auditUpdate.changes.reduce(
+            const {before, after} = auditUpdate.changes.reduce(
                 (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
                 {before: {}, after: {}}
             );
-            if (before.name !== after.name) list['name'] = entry([before.name, after.name], `${before.name} -> ${after.name}`)
-            if (before.channel_id !== after.channel_id) list['channel'] = entry([before.channel_id, after.channel_id], renderChannel(await client.channels.fetch(before.channel_id)) + ` -> ` + renderChannel(await client.channels.fetch(after.channel_id)))
+            if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+            if (before.channel_id !== after.channel_id) list["channel"] = entry([before.channel_id, after.channel_id], renderChannel(await client.channels.fetch(before.channel_id)) + " -> " + renderChannel(await client.channels.fetch(after.channel_id)));
             if (!(Object.keys(list)).length) return;
             list.created = entry(auditUpdate.target.createdTimestamp, renderDelta(auditUpdate.target.createdTimestamp));
             list.edited = entry(after.editedTimestamp, renderDelta(new Date().getTime()));
             list.editedBy = entry(auditUpdate.executor.id, renderUser(auditUpdate.executor));
             audit = auditUpdate;
-            action = "Update"
+            action = "Update";
         } else if (auditDelete && auditDelete.createdTimestamp > audit.createdTimestamp) {
-            let {before, after} = auditDelete.changes.reduce(
+            const {before} = auditDelete.changes.reduce(
                 (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
                 {before: {}, after: {}}
             );
@@ -38,12 +41,12 @@
                 channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
                 created: entry(auditDelete.target.createdTimestamp, renderDelta(auditDelete.target.createdTimestamp)),
                 deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                deletedBy: entry(auditDelete.executor.id, renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user)),
-            }
+                deletedBy: entry(auditDelete.executor.id, renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user))
+            };
             audit = auditDelete;
-            action = "Delete"
+            action = "Delete";
         } else {
-            let {before, after} = auditDelete.changes.reduce(
+            const {before} = auditDelete.changes.reduce(
                 (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
                 {before: {}, after: {}}
             );
@@ -51,19 +54,19 @@
                 name: entry(before.name, `${before.name}`),
                 channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
                 createdBy: entry(auditCreate.executor.id, renderUser((await channel.guild.members.fetch(auditCreate.executor.id)).user)),
-                created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            }
+                created: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+            };
         }
-        let cols = {
+        const cols = {
             "Create": "green",
             "Update": "yellow",
-            "Delete": "red",
-        }
-        let data = {
+            "Delete": "red"
+        };
+        const data = {
             meta: {
-                type: 'webhook' + action,
+                type: "webhook" + action,
                 displayName: `Webhook ${action}d`,
-                calculateType: 'webhookUpdate',
+                calculateType: "webhookUpdate",
                 color: NucleusColors[cols[action]],
                 emoji: "WEBHOOK." + action.toUpperCase(),
                 timestamp: new Date().getTime()
@@ -72,7 +75,7 @@
             hidden: {
                 guild: channel.guild.id
             }
-        }
+        };
         log(data);
-    } catch(e) { console.log(e) }
+    } catch(e) { console.log(e); }
 }
