diff --git a/src/actions/tickets/create.ts b/src/actions/tickets/create.ts
index 237790e..26236d8 100644
--- a/src/actions/tickets/create.ts
+++ b/src/actions/tickets/create.ts
@@ -1,4 +1,10 @@
-import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, ButtonInteraction } from "discord.js";
+import Discord, {
+    ActionRowBuilder,
+    ButtonBuilder,
+    ButtonStyle,
+    CommandInteraction,
+    ButtonInteraction
+} from "discord.js";
 import { tickets, toHexArray } from "../../utils/calculate.js";
 import client from "../../utils/client.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -32,14 +38,18 @@
         });
     }
     let count = 0;
-    const targetChannel: Discord.CategoryChannel | Discord.TextChannel = (await interaction.guild.channels.fetch(config.tickets.category))! as Discord.CategoryChannel | Discord.TextChannel;
+    const targetChannel: Discord.CategoryChannel | Discord.TextChannel = (await interaction.guild.channels.fetch(
+        config.tickets.category
+    ))! as Discord.CategoryChannel | Discord.TextChannel;
     if (targetChannel.type === Discord.ChannelType.GuildCategory) {
         // For channels, the topic is the user ID, then the word Active
         const category = targetChannel as Discord.CategoryChannel;
         category.children.cache.forEach((element) => {
             if (!(element.type === Discord.ChannelType.GuildText)) return;
             if (((element as Discord.TextChannel).topic ?? "").includes(`${interaction.member!.user.id}`)) {
-                if (((element as Discord.TextChannel).topic ?? "").endsWith("Active")) { count++; }
+                if (((element as Discord.TextChannel).topic ?? "").endsWith("Active")) {
+                    count++;
+                }
             }
         });
     } else {
@@ -47,7 +57,9 @@
         const channel = targetChannel as Discord.TextChannel;
         channel.threads.cache.forEach((element: Discord.ThreadChannel) => {
             if (element.name.includes(`${interaction.member!.user.id}`)) {
-                if (element.name.endsWith("Active")) { count++; }
+                if (element.name.endsWith("Active")) {
+                    count++;
+                }
             }
         });
     }
@@ -88,7 +100,9 @@
             }
         });
         for (let i = 0; i < formattedTicketTypes.length; i += 5) {
-            splitFormattedTicketTypes.push(new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5)));
+            splitFormattedTicketTypes.push(
+                new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5))
+            );
         }
         const m = await interaction.reply({
             embeds: [
@@ -106,7 +120,13 @@
         try {
             component = await m.awaitMessageComponent({
                 time: 300000,
-                filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+                filter: (i) => {
+                    return (
+                        i.user.id === interaction.user.id &&
+                        i.channel!.id === interaction.channel!.id &&
+                        i.message.id === m.id
+                    );
+                }
             });
         } catch (e) {
             return;
@@ -131,7 +151,9 @@
             }
         });
         for (let i = 0; i < formattedTicketTypes.length; i += 5) {
-            splitFormattedTicketTypes.push(new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5)));
+            splitFormattedTicketTypes.push(
+                new ActionRowBuilder<ButtonBuilder>().addComponents(formattedTicketTypes.slice(i, i + 5))
+            );
         }
         component.update({
             embeds: [
@@ -252,11 +274,12 @@
             });
         }
     } else {
-        c = await targetChannel.threads.create({name: `${interaction.member!.user.username} - ${interaction.member!.user.id} - Active`,
-                                                autoArchiveDuration: 60 * 24 * 7,
-                                                type: Discord.ChannelType.PrivateThread,
-                                                reason: "Creating ticket"
-                                                }) as Discord.PrivateThreadChannel;
+        c = (await targetChannel.threads.create({
+            name: `${interaction.member!.user.username} - ${interaction.member!.user.id} - Active`,
+            autoArchiveDuration: 60 * 24 * 7,
+            type: Discord.ChannelType.PrivateThread,
+            reason: "Creating ticket"
+        })) as Discord.PrivateThreadChannel;
         c.members.add(interaction.member!.user.id);
         try {
             await c.send({
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index 990b360..1c1e464 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -1,10 +1,18 @@
-import { getCommandMentionByName } from '../../utils/getCommandDataByName.js';
-import Discord, { ActionRowBuilder, ButtonBuilder, ButtonInteraction, PrivateThreadChannel, TextChannel, ButtonStyle, CategoryChannel } from "discord.js";
+import { getCommandMentionByName } from "../../utils/getCommandDataByName.js";
+import Discord, {
+    ActionRowBuilder,
+    ButtonBuilder,
+    ButtonInteraction,
+    PrivateThreadChannel,
+    TextChannel,
+    ButtonStyle,
+    CategoryChannel
+} from "discord.js";
 import client from "../../utils/client.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
-import { preloadPage } from '../../utils/createTemporaryStorage.js';
-import { LoadingEmbed } from '../../utils/defaults.js';
+import { preloadPage } from "../../utils/createTemporaryStorage.js";
+import { LoadingEmbed } from "../../utils/defaults.js";
 
 export default async function (interaction: Discord.CommandInteraction | ButtonInteraction) {
     if (!interaction.guild) return;
@@ -19,7 +27,8 @@
                     .setDescription("This channel isn't a ticket, so you can't delete it.")
                     .setStatus("Danger")
                     .setEmoji("CONTROL.BLOCKCROSS")
-            ], ephemeral: true
+            ],
+            ephemeral: true
         });
     } else if (interaction.channel!.parent!.id !== ticketChannel) {
         return await interaction.reply({
@@ -29,16 +38,23 @@
                     .setDescription("This channel isn't a ticket, so you can't delete it.")
                     .setStatus("Danger")
                     .setEmoji("CONTROL.BLOCKCROSS")
-            ], ephemeral: true
+            ],
+            ephemeral: true
         });
     }
     const channel: PrivateThreadChannel | TextChannel = interaction.channel as PrivateThreadChannel | TextChannel;
-    let status: string | null = ("topic" in interaction.channel) ? interaction.channel!.topic : interaction.channel.name;
+    let status: string | null = "topic" in interaction.channel ? interaction.channel!.topic : interaction.channel.name;
     status = status ?? "";
-    if (status.endsWith("Archived")) { status = "Archived"; }
-    else { status = "Active"; }
+    if (status.endsWith("Archived")) {
+        status = "Archived";
+    } else {
+        status = "Active";
+    }
 
-    const uID = channel.type === Discord.ChannelType.PrivateThread ? channel.name.split(" - ")[1] : channel.topic!.split(" ")[0];
+    const uID =
+        channel.type === Discord.ChannelType.PrivateThread
+            ? channel.name.split(" - ")[1]
+            : channel.topic!.split(" ")[0];
 
     if (status === "Archived") {
         // Delete the ticket
@@ -53,10 +69,7 @@
                 timestamp: Date.now()
             },
             list: {
-                ticketFor: entry(
-                    uID!,
-                    renderUser((await interaction.guild.members.fetch(uID!)).user)
-                ),
+                ticketFor: entry(uID!, renderUser((await interaction.guild.members.fetch(uID!)).user)),
                 closedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
                 closed: entry(Date.now(), renderDelta(Date.now())),
                 ticketChannel: entry(channel.id, channel.name)
@@ -69,26 +82,33 @@
 
         await channel.delete();
     } else if (status === "Active") {
-        await interaction.reply({embeds: LoadingEmbed, fetchReply: true});
+        await interaction.reply({ embeds: LoadingEmbed, fetchReply: true });
         // Archive the ticket
-        await interaction.channel.fetch()
+        await interaction.channel.fetch();
         if (channel.isThread()) {
             channel.setName(`${channel.name.replace("Active", "Archived")}`);
             channel.members.remove(channel.name.split(" - ")[1]!);
         } else {
             channel.setTopic(`${(channel.topic ?? "").replace("Active", "Archived")}`);
-            if (!channel.topic!.includes("Archived")) { channel.setTopic("0 Archived"); }
+            if (!channel.topic!.includes("Archived")) {
+                channel.setTopic("0 Archived");
+            }
             await channel.permissionOverwrites.delete(channel.topic!.split(" ")[0]!);
         }
-        preloadPage(interaction.channel.id, "privacy", "2")
+        preloadPage(interaction.channel.id, "privacy", "2");
         const hasPremium = await client.database.premium.hasPremium(interaction.guild.id);
         await interaction.editReply({
             embeds: [
                 new EmojiEmbed()
                     .setTitle("Archived Ticket")
-                    .setDescription(`This ticket has been Archived. Type ${getCommandMentionByName("ticket/close")} to delete it.\n` +
-                        hasPremium ? ("Creating a transcript will delete all messages in this ticket" +
-                        `\n\nFor more info on transcripts, check ${getCommandMentionByName("privacy")}`): "")
+                    .setDescription(
+                        `This ticket has been Archived. Type ${getCommandMentionByName(
+                            "ticket/close"
+                        )} to delete it.\n` + hasPremium
+                            ? "Creating a transcript will delete all messages in this ticket" +
+                                  `\n\nFor more info on transcripts, check ${getCommandMentionByName("privacy")}`
+                            : ""
+                    )
                     .setStatus("Warning")
                     .setEmoji("GUILD.TICKET.ARCHIVED")
             ],
@@ -103,12 +123,12 @@
                     ].concat(
                         hasPremium
                             ? [
-                                    new ButtonBuilder()
-                                        .setLabel("Create Transcript and Delete")
-                                        .setStyle(ButtonStyle.Primary)
-                                        .setCustomId("createtranscript")
-                                        .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
-                                ]
+                                  new ButtonBuilder()
+                                      .setLabel("Create Transcript and Delete")
+                                      .setStyle(ButtonStyle.Primary)
+                                      .setCustomId("createtranscript")
+                                      .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
+                              ]
                             : []
                     )
                 )
@@ -124,10 +144,7 @@
                 timestamp: Date.now()
             },
             list: {
-                ticketFor: entry(
-                    uID!,
-                    renderUser((await interaction.guild.members.fetch(uID!)).user)
-                ),
+                ticketFor: entry(uID!, renderUser((await interaction.guild.members.fetch(uID!)).user)),
                 archivedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
                 archived: entry(Date.now(), renderDelta(Date.now())),
                 ticketChannel: entry(channel.id, renderChannel(channel))
@@ -141,12 +158,13 @@
     return;
 }
 
-
 async function purgeByUser(member: string, guild: string) {
     const config = await client.database.guilds.read(guild);
     const fetchedGuild = await client.guilds.fetch(guild);
     if (!config.tickets.category) return;
-    const tickets: CategoryChannel | TextChannel | undefined = fetchedGuild.channels.cache.get(config.tickets.category) as CategoryChannel | TextChannel | undefined;
+    const tickets: CategoryChannel | TextChannel | undefined = fetchedGuild.channels.cache.get(
+        config.tickets.category
+    ) as CategoryChannel | TextChannel | undefined;
     if (!tickets) return;
     let deleted = 0;
     if (tickets.type === Discord.ChannelType.GuildCategory) {
@@ -154,7 +172,7 @@
         const category = tickets as Discord.CategoryChannel;
         category.children.cache.forEach((element) => {
             if (!(element.type === Discord.ChannelType.GuildText)) return;
-            if (!(((element as Discord.TextChannel).topic ?? "").includes(member))) return;
+            if (!((element as Discord.TextChannel).topic ?? "").includes(member)) return;
             try {
                 element.delete();
                 deleted++;
@@ -175,7 +193,7 @@
             }
         });
     }
-    if (!deleted) return
+    if (!deleted) return;
     const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
     const data = {
         meta: {
