diff --git a/src/premium/attachmentLogs.ts b/src/premium/attachmentLogs.ts
index b2c8391..e719f22 100644
--- a/src/premium/attachmentLogs.ts
+++ b/src/premium/attachmentLogs.ts
@@ -1,4 +1,4 @@
-import { getCommandMentionByName } from './../utils/getCommandDataByName.js';
+import { getCommandMentionByName } from "./../utils/getCommandDataByName.js";
 import client from "../utils/client.js";
 import keyValueList from "../utils/generateKeyValueList.js";
 import singleNotify from "../utils/singleNotify.js";
@@ -39,7 +39,9 @@
             singleNotify(
                 "noAttachmentLogChannel",
                 message.guild.id,
-                `No channel set for attachment logging. You can set one with ${getCommandMentionByName("settings/logs/attachments")}`,
+                `No channel set for attachment logging. You can set one with ${getCommandMentionByName(
+                    "settings/logs/attachments"
+                )}`,
                 "Warning"
             );
             return { files: attachments };
@@ -49,7 +51,9 @@
             singleNotify(
                 "attachmentLogChannelDeleted",
                 message.guild.id,
-                `Your attachment history channel was deleted or is not longer accessible. You can set a new one with ${getCommandMentionByName("settings/logs/attachments")}`,
+                `Your attachment history channel was deleted or is not longer accessible. You can set a new one with ${getCommandMentionByName(
+                    "settings/logs/attachments"
+                )}`,
                 "Warning"
             );
             return { files: attachments };
@@ -63,7 +67,7 @@
                             messageId: `\`${message.id}\``,
                             sentBy: renderUser(message.author),
                             sentIn: renderChannel(message.channel as GuildTextBasedChannel),
-                            sent: renderDelta((new Date(message.createdTimestamp)).getTime())
+                            sent: renderDelta(new Date(message.createdTimestamp).getTime())
                         }) + `\n[[Jump to message]](${message.url})`
                     )
                     .setEmoji("ICONS.ATTACHMENT")
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index cdbc7b9..e7a0171 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -13,13 +13,13 @@
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 import client from "../utils/client.js";
-import { messageException } from '../utils/createTemporaryStorage.js';
+import { messageException } from "../utils/createTemporaryStorage.js";
 
 const noTopic = new EmojiEmbed()
     .setTitle("User not found")
     .setDescription("There is no user associated with this ticket.")
     .setStatus("Danger")
-    .setEmoji("CONTROL.BLOCKCROSS")
+    .setEmoji("CONTROL.BLOCKCROSS");
 
 export default async function (interaction: CommandInteraction | MessageComponentInteraction) {
     if (interaction.channel === null) return;
@@ -34,17 +34,16 @@
         const deleted = await (interaction.channel as TextChannel).bulkDelete(fetched, true);
         deletedCount = deleted.size;
         messages = messages.concat(Array.from(deleted.values() as Iterable<Message>));
-        if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id)
+        if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id);
     } while (deletedCount === 100);
-    messages = messages.filter(message => !(
-        message.components.some(
-            component => component.components.some(
-                child => child.customId?.includes("transcript") ?? false
+    messages = messages.filter(
+        (message) =>
+            !message.components.some((component) =>
+                component.components.some((child) => child.customId?.includes("transcript") ?? false)
             )
-        )
-    ));
+    );
 
-    let topic
+    let topic;
     let member: GuildMember = interaction.guild?.members.me!;
     if (interaction.channel instanceof TextChannel) {
         topic = interaction.channel.topic;
@@ -53,23 +52,24 @@
         if (mem) member = mem;
     } else {
         topic = interaction.channel.name;
-        const split = topic.split("-").map(p => p.trim()) as [string, string, string];
-        const mem = interaction.guild!.members.cache.get(split[1])
+        const split = topic.split("-").map((p) => p.trim()) as [string, string, string];
+        const mem = interaction.guild!.members.cache.get(split[1]);
         if (mem) member = mem;
     }
 
     const newOut = await client.database.transcripts.createTranscript(messages, interaction, member);
 
     const [code, key, iv] = await client.database.transcripts.create(newOut);
-    if(!code) return await interaction.reply({
-        embeds: [
-            new EmojiEmbed()
-                .setTitle("Error")
-                .setDescription("An error occurred while creating the transcript.")
-                .setStatus("Danger")
-                .setEmoji("CONTROL.BLOCKCROSS")
-        ]
-    })
+    if (!code)
+        return await interaction.reply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Error")
+                    .setDescription("An error occurred while creating the transcript.")
+                    .setStatus("Danger")
+                    .setEmoji("CONTROL.BLOCKCROSS")
+            ]
+        });
     const guildConfig = await client.database.guilds.read(interaction.guild!.id);
     const m: Message = (await interaction.reply({
         embeds: [
@@ -86,7 +86,10 @@
         ],
         components: [
             new ActionRowBuilder<ButtonBuilder>().addComponents([
-                new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://testing.coded.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`),
+                new ButtonBuilder()
+                    .setLabel("View")
+                    .setStyle(ButtonStyle.Link)
+                    .setURL(`https://testing.coded.codes/nucleus/transcript/${code}?key=${key}&iv=${iv}`),
                 new ButtonBuilder()
                     .setLabel("Delete")
                     .setStyle(ButtonStyle.Danger)
@@ -100,7 +103,13 @@
     try {
         i = 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
+                );
+            }
         });
         await i.deferUpdate();
     } catch {
