diff --git a/src/utils/log.ts b/src/utils/log.ts
index f9f751e..6baa0a5 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -7,18 +7,17 @@
 
 const wait = promisify(setTimeout);
 
-
 export class Logger {
     renderUser(user: Discord.User | string) {
         if (typeof user === "string") return `${user} [<@${user}>]`;
         return `${user.username} [<@${user.id}>]`;
     }
     renderTime(t: number) {
-        t = Math.floor(t /= 1000);
+        t = Math.floor((t /= 1000));
         return `<t:${t}:D> at <t:${t}:T>`;
     }
     renderDelta(t: number) {
-        t = Math.floor(t /= 1000);
+        t = Math.floor((t /= 1000));
         return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
     }
     renderNumberDelta(num1: number, num2: number) {
@@ -35,19 +34,23 @@
         return `${role.name} [<@&${role.id}>]`;
     }
     renderEmoji(emoji: Discord.GuildEmoji) {
-        return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
+        return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${
+            emoji.name
+        }:\`]`;
     }
 
     public readonly NucleusColors = {
-        red: 0xF27878,
-        yellow: 0xF2D478,
-        green: 0x68D49E
-
+        red: 0xf27878,
+        yellow: 0xf2d478,
+        green: 0x68d49e
     };
 
-    async getAuditLog(guild: Discord.Guild, event: Discord.GuildAuditLogsResolvable): Promise<Discord.GuildAuditLogsEntry[]>{
+    async getAuditLog(
+        guild: Discord.Guild,
+        event: Discord.GuildAuditLogsResolvable
+    ): Promise<Discord.GuildAuditLogsEntry[]> {
         await wait(250);
-        const auditLog = await guild.fetchAuditLogs({type: event});
+        const auditLog = await guild.fetchAuditLogs({ type: event });
         return auditLog as unknown as Discord.GuildAuditLogsEntry[];
     }
 
@@ -56,16 +59,23 @@
         const config = await client.database.guilds.read(log.hidden.guild);
         if (!config.logging.logs.enabled) return;
         if (!(log.meta.calculateType === true)) {
-            if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log("Not logging this type of event");
+            if (
+                !toHexArray(config.logging.logs.toLog).includes(
+                    log.meta.calculateType
+                )
+            )
+                return console.log("Not logging this type of event");
         }
         if (config.logging.logs.channel) {
-            const channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
+            const channel = (await client.channels.fetch(
+                config.logging.logs.channel
+            )) as Discord.TextChannel | null;
             const description: Record<string, string> = {};
-            Object.entries(log.list).map(entry => {
+            Object.entries(log.list).map((entry) => {
                 const key: string = entry[0];
                 // eslint-disable-next-line @typescript-eslint/no-explicit-any
                 const value: any = entry[1];
-                if(value.displayValue) {
+                if (value.displayValue) {
                     description[key] = value.displayValue;
                 } else {
                     description[key] = value;
@@ -74,19 +84,22 @@
             if (channel) {
                 log.separate = log.separate || {};
                 const embed = new Discord.MessageEmbed()
-                    .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
+                    .setTitle(
+                        `${getEmojiByName(log.meta.emoji)} ${
+                            log.meta.displayName
+                        }`
+                    )
                     .setDescription(
                         (log.separate.start ? log.separate.start + "\n" : "") +
-                        generateKeyValueList(description) +
-                        (log.separate.end ? "\n" + log.separate.end : "")
+                            generateKeyValueList(description) +
+                            (log.separate.end ? "\n" + log.separate.end : "")
                     )
                     .setTimestamp(log.meta.timestamp)
                     .setColor(log.meta.color);
-                channel.send({embeds: [embed]});
+                channel.send({ embeds: [embed] });
             }
         }
     }
 }
 
-
 export default {};
