diff --git a/src/context/messages/purgeto.ts b/src/context/messages/purgeto.ts
index 3d7e95a..d2191d1 100644
--- a/src/context/messages/purgeto.ts
+++ b/src/context/messages/purgeto.ts
@@ -1,18 +1,28 @@
-import confirmationMessage from '../../utils/confirmationMessage.js';
-import EmojiEmbed from '../../utils/generateEmojiEmbed.js';
-import { LoadingEmbed } from '../../utils/defaults.js';
-import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, GuildMember, GuildTextBasedChannel, Message, MessageContextMenuCommandInteraction } from "discord.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import { LoadingEmbed } from "../../utils/defaults.js";
+import Discord, {
+    ActionRowBuilder,
+    ButtonBuilder,
+    ButtonStyle,
+    ContextMenuCommandBuilder,
+    GuildMember,
+    GuildTextBasedChannel,
+    Message,
+    MessageContextMenuCommandInteraction
+} from "discord.js";
 import client from "../../utils/client.js";
-import { messageException } from '../../utils/createTemporaryStorage.js';
+import { messageException } from "../../utils/createTemporaryStorage.js";
 
-const command = new ContextMenuCommandBuilder()
-    .setName("Purge up to here")
-
+const command = new ContextMenuCommandBuilder().setName("Purge up to here");
 
 async function waitForButton(m: Discord.Message, member: Discord.GuildMember): Promise<boolean> {
     let component;
     try {
-        component = m.awaitMessageComponent({ time: 200000, filter: (i) => i.user.id === member.id && i.channel!.id === m.channel.id && i.message.id === m.id });
+        component = m.awaitMessageComponent({
+            time: 200000,
+            filter: (i) => i.user.id === member.id && i.channel!.id === m.channel.id && i.message.id === m.id
+        });
     } catch (e) {
         return false;
     }
@@ -20,7 +30,6 @@
     return true;
 }
 
-
 const callback = async (interaction: MessageContextMenuCommandInteraction) => {
     await interaction.targetMessage.fetch();
     const targetMessage = interaction.targetMessage;
@@ -34,56 +43,74 @@
 
     const history: Discord.Collection<string, Discord.Message> = await channel.messages.fetch({ limit: 100 });
     if (Date.now() - targetMessage.createdTimestamp > 2 * 7 * 24 * 60 * 60 * 1000) {
-        const m = await interaction.editReply({ embeds: [new EmojiEmbed()
-            .setTitle("Purge")
-            .setDescription("The message you selected is older than 2 weeks. Discord only allows bots to delete messages that are 2 weeks old or younger.")
-            .setEmoji("CHANNEL.PURGE.RED")
-            .setStatus("Danger")
-        ], components: [
-            new ActionRowBuilder<ButtonBuilder>().addComponents(
-                new ButtonBuilder()
-                    .setCustomId("oldest")
-                    .setLabel("Select first allowed message")
-                    .setStyle(ButtonStyle.Primary),
-            )
-        ]});
-        if (!await waitForButton(m, interaction.member as Discord.GuildMember)) return;
+        const m = await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Purge")
+                    .setDescription(
+                        "The message you selected is older than 2 weeks. Discord only allows bots to delete messages that are 2 weeks old or younger."
+                    )
+                    .setEmoji("CHANNEL.PURGE.RED")
+                    .setStatus("Danger")
+            ],
+            components: [
+                new ActionRowBuilder<ButtonBuilder>().addComponents(
+                    new ButtonBuilder()
+                        .setCustomId("oldest")
+                        .setLabel("Select first allowed message")
+                        .setStyle(ButtonStyle.Primary)
+                )
+            ]
+        });
+        if (!(await waitForButton(m, interaction.member as Discord.GuildMember))) return;
     } else if (!history.has(targetMessage.id)) {
-        const m = await interaction.editReply({ embeds: [new EmojiEmbed()
-            .setTitle("Purge")
-            .setDescription("The message you selected is not in the last 100 messages in this channel. Discord only allows bots to delete 100 messages at a time.")
-            .setEmoji("CHANNEL.PURGE.YELLOW")
-            .setStatus("Warning")
-        ], components: [
-            new ActionRowBuilder<ButtonBuilder>().addComponents(
-                new ButtonBuilder()
-                    .setCustomId("oldest")
-                    .setLabel("Select first allowed message")
-                    .setStyle(ButtonStyle.Primary),
-            )
-        ]});
-        if (!await waitForButton(m, interaction.member as Discord.GuildMember)) return;
+        const m = await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Purge")
+                    .setDescription(
+                        "The message you selected is not in the last 100 messages in this channel. Discord only allows bots to delete 100 messages at a time."
+                    )
+                    .setEmoji("CHANNEL.PURGE.YELLOW")
+                    .setStatus("Warning")
+            ],
+            components: [
+                new ActionRowBuilder<ButtonBuilder>().addComponents(
+                    new ButtonBuilder()
+                        .setCustomId("oldest")
+                        .setLabel("Select first allowed message")
+                        .setStyle(ButtonStyle.Primary)
+                )
+            ]
+        });
+        if (!(await waitForButton(m, interaction.member as Discord.GuildMember))) return;
     } else {
         allowedMessage = targetMessage;
     }
 
     if (!allowedMessage) {
         // Find the oldest message thats younger than 2 weeks
-        const messages = history.filter(m => Date.now() - m.createdTimestamp < 2 * 7 * 24 * 60 * 60 * 1000);
+        const messages = history.filter((m) => Date.now() - m.createdTimestamp < 2 * 7 * 24 * 60 * 60 * 1000);
         allowedMessage = messages.sort((a, b) => a.createdTimestamp - b.createdTimestamp).first();
     }
 
     if (!allowedMessage) {
-        await interaction.editReply({ embeds: [new EmojiEmbed()
-            .setTitle("Purge")
-            .setDescription("There are no valid messages in the last 100 messages. (No messages younger than 2 weeks)")
-            .setEmoji("CHANNEL.PURGE.RED")
-            .setStatus("Danger")
-        ], components: [] });
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Purge")
+                    .setDescription(
+                        "There are no valid messages in the last 100 messages. (No messages younger than 2 weeks)"
+                    )
+                    .setEmoji("CHANNEL.PURGE.RED")
+                    .setStatus("Danger")
+            ],
+            components: []
+        });
         return;
     }
 
-    let reason: string | null = null
+    let reason: string | null = null;
     let confirmation;
     let chosen = false;
     let timedOut = false;
@@ -95,8 +122,9 @@
             .setTitle("Purge")
             .setDescription(
                 `[[Selected Message]](${allowedMessage.url})\n\n` +
-                (reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*") + "\n\n" +
-                `Are you sure you want to delete all messages from below the selected message?`
+                    (reason ? "\n> " + reason.replaceAll("\n", "\n> ") : "*No reason provided*") +
+                    "\n\n" +
+                    `Are you sure you want to delete all messages from below the selected message?`
             )
             .addCustomBoolean(
                 "includeSelected",
@@ -121,8 +149,8 @@
             .setColor("Danger")
             .addReasonButton(reason ?? "")
             .setFailedMessage("No changes were made", "Success", "CHANNEL.PURGE.GREEN")
-            .send(true)
-        reason = reason ?? ""
+            .send(true);
+        reason = reason ?? "";
         if (confirmation.cancelled) timedOut = true;
         else if (confirmation.success !== undefined) chosen = true;
         else if (confirmation.newReason) reason = confirmation.newReason;
@@ -133,9 +161,9 @@
     } while (!chosen && !timedOut);
     if (timedOut || !confirmation.success) return;
     const filteredMessages = history
-        .filter(m => m.createdTimestamp >= allowedMessage!.createdTimestamp)  // older than selected
-        .filter(m => deleteUser ? m.author.id === targetMember.id : true)  // only selected user
-        .filter(m => deleteSelected ? true : m.id !== allowedMessage!.id)  // include selected
+        .filter((m) => m.createdTimestamp >= allowedMessage!.createdTimestamp) // older than selected
+        .filter((m) => (deleteUser ? m.author.id === targetMember.id : true)) // only selected user
+        .filter((m) => (deleteSelected ? true : m.id !== allowedMessage!.id)); // include selected
 
     const deleted = await (channel as GuildTextBasedChannel).bulkDelete(filteredMessages, true);
     if (deleted.size === 0) {
@@ -183,16 +211,24 @@
         }
     };
     log(data);
-    const messages: Message[] = deleted.map(m => m).filter(m => m instanceof Message).map(m => m as Message);
-    if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id)
-    const messageArray: Message[] = messages.filter(message => !(
-        message!.components.some(
-            component => component.components.some(
-                child => child.customId?.includes("transcript") ?? false
-            )
+    const messages: Message[] = deleted
+        .map((m) => m)
+        .filter((m) => m instanceof Message)
+        .map((m) => m as Message);
+    if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id);
+    const messageArray: Message[] = messages
+        .filter(
+            (message) =>
+                !message!.components.some((component) =>
+                    component.components.some((child) => child.customId?.includes("transcript") ?? false)
+                )
         )
-    )).map(message => message as Message);
-    const transcript = await client.database.transcripts.createTranscript(messageArray, interaction, interaction.member as GuildMember);
+        .map((message) => message as Message);
+    const transcript = await client.database.transcripts.createTranscript(
+        messageArray,
+        interaction,
+        interaction.member as GuildMember
+    );
 
     const [code, key, iv] = await client.database.transcripts.create(transcript);
 
@@ -206,14 +242,18 @@
         ],
         components: [
             new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
-                new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`).setDisabled(!code),
+                new ButtonBuilder()
+                    .setLabel("View")
+                    .setStyle(ButtonStyle.Link)
+                    .setURL(`https://clicks.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`)
+                    .setDisabled(!code)
             ])
         ]
     });
-}
+};
 
 const check = async (_interaction: MessageContextMenuCommandInteraction) => {
     return true;
-}
+};
 
-export { command, callback, check }
+export { command, callback, check };
