diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 473fa52..4cdbdb2 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -3,10 +3,25 @@
 export async function callback(client, message) {
     try {
         if (message.author.id === client.user.id) return;
-        if (client.noLog.includes(`${message.guild.id}/${message.channel.id}/${message.id}`)) return;
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger;
+        if (
+            client.noLog.includes(
+                `${message.guild.id}/${message.channel.id}/${message.id}`
+            )
+        )
+            return;
+        const {
+            getAuditLog,
+            log,
+            NucleusColors,
+            entry,
+            renderUser,
+            renderDelta,
+            renderChannel
+        } = message.channel.client.logger;
         const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
-        const audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
+        const audit = auditLog.entries
+            .filter((entry) => entry.target.id === message.author.id)
+            .first();
         if (audit) {
             if (audit.createdAt - 100 < new Date().getTime()) return;
         }
@@ -14,10 +29,19 @@
         let content = message.cleanContent;
         content.replace("`", "\\`");
         if (content.length > 256) content = content.substring(0, 253) + "...";
-        const attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi) ?? []).length;
+        const attachments =
+            message.attachments.size +
+            (
+                message.content.match(
+                    /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi
+                ) ?? []
+            ).length;
         let attachmentJump = "";
-        const config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
-        if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+        const config = (await client.database.guilds.read(message.guild.id))
+            .logging.attachments.saved[message.channel.id + message.id];
+        if (config) {
+            attachmentJump = ` [[View attachments]](${config})`;
+        }
         const data = {
             meta: {
                 type: "messageDelete",
@@ -28,18 +52,28 @@
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
+                start: content
+                    ? `**Message:**\n\`\`\`${content}\`\`\``
+                    : "**Message:** *Message had no content*"
             },
             list: {
                 messageId: entry(message.id, `\`${message.id}\``),
                 sentBy: entry(message.author.id, renderUser(message.author)),
-                sentIn: entry(message.channel.id, renderChannel(message.channel)),
-                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+                sentIn: entry(
+                    message.channel.id,
+                    renderChannel(message.channel)
+                ),
+                deleted: entry(
+                    new Date().getTime(),
+                    renderDelta(new Date().getTime())
+                ),
                 mentions: message.mentions.users.size,
                 attachments: entry(attachments, attachments + attachmentJump),
                 repliedTo: entry(
                     message.reference.messageId || null,
-                    message.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
+                    message.reference.messageId
+                        ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})`
+                        : "None"
                 )
             },
             hidden: {
@@ -47,5 +81,7 @@
             }
         };
         log(data);
-    } catch(e) { console.log(e); }
+    } catch (e) {
+        console.log(e);
+    }
 }
