diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 8d9ef10..236bc0f 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -6,9 +6,10 @@
 
 export async function callback(client: NucleusClient, oldRole: Role, newRole: Role) {
     const { getAuditLog, isLogging, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
-    if (!await isLogging(newRole.guild.id, "guildRoleUpdate")) return;
-    const auditLog = (await getAuditLog(newRole.guild as Guild, AuditLogEvent.RoleUpdate))
-        .filter((entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === newRole.id)[0];
+    if (!(await isLogging(newRole.guild.id, "guildRoleUpdate"))) return;
+    const auditLog = (await getAuditLog(newRole.guild as Guild, AuditLogEvent.RoleUpdate)).filter(
+        (entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === newRole.id
+    )[0];
     if (!auditLog) return;
     if (auditLog.executor!.id === client.user!.id) return;
 
@@ -16,22 +17,40 @@
         roleId: entry(newRole.id, `\`${newRole.id}\``),
         role: entry(newRole.id, renderRole(newRole)),
         edited: entry(Date.now(), renderDelta(Date.now())),
-        editedBy: entry(auditLog.executor!.id, renderUser((await newRole.guild.members.fetch(auditLog.executor!.id)).user))
+        editedBy: entry(
+            auditLog.executor!.id,
+            renderUser((await newRole.guild.members.fetch(auditLog.executor!.id)).user)
+        )
     };
     const mentionable = ["", ""];
     const hoist = ["", ""];
-    mentionable[0] = oldRole.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-    mentionable[1] = newRole.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+    mentionable[0] = oldRole.mentionable
+        ? `${getEmojiByName("CONTROL.TICK")} Yes`
+        : `${getEmojiByName("CONTROL.CROSS")} No`;
+    mentionable[1] = newRole.mentionable
+        ? `${getEmojiByName("CONTROL.TICK")} Yes`
+        : `${getEmojiByName("CONTROL.CROSS")} No`;
     hoist[0] = oldRole.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
     hoist[1] = newRole.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-    if (oldRole.name !== newRole.name) changes["name"] = entry([oldRole.name, newRole.name], `${oldRole.name} -> ${newRole.name}`);
+    if (oldRole.name !== newRole.name)
+        changes["name"] = entry([oldRole.name, newRole.name], `${oldRole.name} -> ${newRole.name}`);
     if (oldRole.position !== newRole.position)
-        changes["position"] = entry([oldRole.position.toString(), newRole.position.toString()], `${oldRole.position} -> ${newRole.position}`);
-    if (oldRole.hoist !== newRole.hoist) changes["showInMemberList"] = entry([oldRole.hoist, newRole.hoist], `${hoist[0]} -> ${hoist[1]}`);
+        changes["position"] = entry(
+            [oldRole.position.toString(), newRole.position.toString()],
+            `${oldRole.position} -> ${newRole.position}`
+        );
+    if (oldRole.hoist !== newRole.hoist)
+        changes["showInMemberList"] = entry([oldRole.hoist, newRole.hoist], `${hoist[0]} -> ${hoist[1]}`);
     if (oldRole.mentionable !== newRole.mentionable)
-        changes["mentionable"] = entry([oldRole.mentionable, newRole.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+        changes["mentionable"] = entry(
+            [oldRole.mentionable, newRole.mentionable],
+            `${mentionable[0]} -> ${mentionable[1]}`
+        );
     if (oldRole.hexColor !== newRole.hexColor)
-        changes["color"] = entry([oldRole.hexColor, newRole.hexColor], `\`${oldRole.hexColor}\` -> \`${newRole.hexColor}\``);
+        changes["color"] = entry(
+            [oldRole.hexColor, newRole.hexColor],
+            `\`${oldRole.hexColor}\` -> \`${newRole.hexColor}\``
+        );
     if (oldRole.permissions.bitfield !== newRole.permissions.bitfield) {
         changes["permissions"] = entry(
             [oldRole.permissions.bitfield.toString(), newRole.permissions.bitfield.toString()],
