diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index f7cccaf..05c5494 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -62,7 +62,11 @@
         this.inverted = inverted;
         return this;
     }
-    setFailedMessage(text: string, failedStatus: "Success" | "Danger" | "Warning" | null, failedEmoji: string | null = null) {
+    setFailedMessage(
+        text: string,
+        failedStatus: "Success" | "Danger" | "Warning" | null,
+        failedEmoji: string | null = null
+    ) {
         this.failedMessage = text;
         this.failedStatus = failedStatus;
         this.failedEmoji = failedEmoji;
@@ -138,10 +142,14 @@
                 );
             const components = [];
             for (let i = 0; i < fullComponents.length; i += 5) {
-                components.push(new ActionRowBuilder<
-                    Discord.ButtonBuilder | Discord.StringSelectMenuBuilder |
-                    Discord.RoleSelectMenuBuilder | Discord.UserSelectMenuBuilder
-                >().addComponents(fullComponents.slice(i, i + 5)));
+                components.push(
+                    new ActionRowBuilder<
+                        | Discord.ButtonBuilder
+                        | Discord.StringSelectMenuBuilder
+                        | Discord.RoleSelectMenuBuilder
+                        | Discord.UserSelectMenuBuilder
+                    >().addComponents(fullComponents.slice(i, i + 5))
+                );
             }
             const object = {
                 embeds: [
@@ -158,7 +166,8 @@
                                         } else {
                                             return v.notValue ? `*${v.notValue}*\n` : "";
                                         }
-                                    }).join("")
+                                    })
+                                    .join("")
                         )
                         .setStatus(this.color)
                 ],
@@ -181,7 +190,8 @@
             let component;
             try {
                 component = await m.awaitMessageComponent({
-                    filter: (i) => i.user.id === this.interaction.user.id && i.channel!.id === this.interaction.channel!.id,
+                    filter: (i) =>
+                        i.user.id === this.interaction.user.id && i.channel!.id === this.interaction.channel!.id,
                     time: 300000
                 });
             } catch (e) {
@@ -244,12 +254,15 @@
                 });
                 let out;
                 try {
-                    out = await modalInteractionCollector(m, this.interaction.user) as Discord.ModalSubmitInteraction | null;
+                    out = (await modalInteractionCollector(
+                        m,
+                        this.interaction.user
+                    )) as Discord.ModalSubmitInteraction | null;
                 } catch (e) {
                     cancelled = true;
                     continue;
                 }
-                if (out === null  || out.isButton()) {
+                if (out === null || out.isButton()) {
                     cancelled = true;
                     continue;
                 }
@@ -270,28 +283,31 @@
         const returnValue: Awaited<ReturnType<typeof this.send>> = {};
 
         if (cancelled) {
-            await this.timeoutError()
+            await this.timeoutError();
             returnValue.cancelled = true;
         }
         if (success === false) {
             await this.interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle(this.title)
-                    .setDescription(this.failedMessage ?? "*Message timed out*")
-                    .setStatus(this.failedStatus ?? "Danger")
-                    .setEmoji(this.failedEmoji ?? this.redEmoji ?? this.emoji)
-                ], components: []
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle(this.title)
+                        .setDescription(this.failedMessage ?? "*Message timed out*")
+                        .setStatus(this.failedStatus ?? "Danger")
+                        .setEmoji(this.failedEmoji ?? this.redEmoji ?? this.emoji)
+                ],
+                components: []
             });
-            return {success: false}
+            return { success: false };
         }
         if (returnComponents || success !== undefined) returnValue.components = this.customButtons;
         if (success !== undefined) returnValue.success = success;
         if (newReason) returnValue.newReason = newReason;
 
-        const typedReturnValue = returnValue as {cancelled: true} |
-        { success: boolean, components: Record<string, CustomBoolean<unknown>>, newReason?: string} |
-        { newReason: string, components: Record<string, CustomBoolean<unknown>> } |
-        { components: Record<string, CustomBoolean<unknown>> };
+        const typedReturnValue = returnValue as
+            | { cancelled: true }
+            | { success: boolean; components: Record<string, CustomBoolean<unknown>>; newReason?: string }
+            | { newReason: string; components: Record<string, CustomBoolean<unknown>> }
+            | { components: Record<string, CustomBoolean<unknown>> };
 
         return typedReturnValue;
     }
@@ -306,7 +322,7 @@
                     .setEmoji("CONTROL.BLOCKCROSS")
             ],
             components: []
-        })
+        });
     }
 }
 
