diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 89a721c..ff36ce0 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -2,27 +2,55 @@
 export const event = "threadUpdate";
 
 export async function callback(client, before, after) {
-    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger;
+    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();
+    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}\``),
+        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}`);
+        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 })}`);
+        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)}`);
+        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));
+    list.updated = entry(
+        new Date().getTime(),
+        renderDelta(new Date().getTime())
+    );
+    list.updatedBy = entry(audit.executor.id, renderUser(audit.executor));
     const data = {
         meta: {
             type: "channelUpdate",
