diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 89692e8..6717661 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -5,118 +5,218 @@
 
 export async function callback(client, oc, nc) {
     const config = await client.memory.readGuildInfo(nc.guild.id);
-    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger;
+    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;
 
     const auditLog = await getAuditLog(nc.guild, "CHANNEL_UPDATE");
-    const audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
+    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 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))
+        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}`);
+    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)}`
-        );
+        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";
-    }
+            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 (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:{
+        meta: {
             type: "channelUpdate",
             displayName: displayName + " Edited",
             calculateType: "channelUpdate",
@@ -130,4 +230,4 @@
         }
     };
     log(data);
-}
\ No newline at end of file
+}
