diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index 2cb1de8..2c87807 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -4,9 +4,12 @@
 
 export async function callback(client, before, after) {
     await statsChannelUpdate(client, after.me);
-    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
+    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();
+    const audit = auditLog.entries
+        .filter((entry) => entry.target.id === after.id)
+        .first();
     if (audit.executor.id === client.user.id) return;
     const list = {};
 
@@ -29,18 +32,65 @@
         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 (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));
+    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",
