diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index dfdc3fb..a615fae 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -1,6 +1,6 @@
 import Discord, { CommandInteraction, MessageActionRow, Message, MessageButton, TextInputComponent } from "discord.js";
 import { modalInteractionCollector } from "./dualCollector.js";
-import EmojiEmbed from "./generateEmojiEmbed.js"
+import EmojiEmbed from "./generateEmojiEmbed.js";
 import getEmojiByName from "./getEmojiByName.js";
 
 
@@ -8,7 +8,7 @@
     title: string;
     disabled: boolean;
     value: string | null;
-    emoji: string | null;
+    emoji: string | undefined;
     active: boolean;
     onClick: () => Promise<T>;
     response: T | null;
@@ -16,33 +16,33 @@
 
 class confirmationMessage {
     interaction: CommandInteraction;
-    title: string = "";
-    emoji: string = "";
-    description: string = "";
-    color: string = "";
+    title = "";
+    emoji = "";
+    description = "";
+    color = "";
     customButtons: {[index:string]: CustomBoolean<unknown>} = {};
-    inverted: boolean = false;
+    inverted = false;
     reason: string | null = null;
 
     constructor(interaction: CommandInteraction) {
         this.interaction = interaction;
     }
 
-    setTitle(title: string) { this.title = title; return this }
-    setEmoji(emoji: string) { this.emoji = emoji; return this }
-    setDescription(description: string) { this.description = description; return this }
-    setColor(color: string) { this.color = color; return this }
-    setInverted(inverted: boolean) { this.inverted = inverted; return this }
+    setTitle(title: string) { this.title = title; return this; }
+    setEmoji(emoji: string) { this.emoji = emoji; return this; }
+    setDescription(description: string) { this.description = description; return this; }
+    setColor(color: string) { this.color = color; return this; }
+    setInverted(inverted: boolean) { this.inverted = inverted; return this; }
     addCustomBoolean(customId: string, title: string, disabled: boolean, callback: () => Promise<unknown> | null, callbackClicked: string | null, emoji?: string, initial?: boolean) {        this.customButtons[customId] = {
-            title: title,
-            disabled: disabled,
-            value: callbackClicked,
-            emoji: emoji,
-            active: initial ?? false,
-            onClick: callback ?? (() => null),
-            response: null,
-        }
-        return this;
+        title: title,
+        disabled: disabled,
+        value: callbackClicked,
+        emoji: emoji,
+        active: initial ?? false,
+        onClick: callback ?? (() => null),
+        response: null
+    };
+    return this;
     }
     addReasonButton(reason: string) {
         this.reason = reason;
@@ -50,7 +50,7 @@
     }
     async send(editOnly?: boolean) {
         while (true) {
-            let fullComponents = [
+            const fullComponents = [
                 new Discord.MessageButton()
                     .setCustomId("yes")
                     .setLabel("Confirm")
@@ -61,27 +61,27 @@
                     .setLabel("Cancel")
                     .setStyle("SECONDARY")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-            ]
+            ];
             Object.entries(this.customButtons).forEach(([k, v]) => {
                 fullComponents.push(new Discord.MessageButton()
                     .setCustomId(k)
                     .setLabel(v.title)
                     .setStyle(v.active ? "SUCCESS" : "PRIMARY")
                     .setEmoji(getEmojiByName(v.emoji, "id"))
-                    .setDisabled(v.disabled))
-            })
+                    .setDisabled(v.disabled));
+            });
             if (this.reason !== null) fullComponents.push(new Discord.MessageButton()
                 .setCustomId("reason")
-                .setLabel(`Edit Reason`)
+                .setLabel("Edit Reason")
                 .setStyle("PRIMARY")
                 .setEmoji(getEmojiByName("ICONS.EDIT", "id"))
                 .setDisabled(false)
-            )
-            let components = []
+            );
+            const components = [];
             for (let i = 0; i < fullComponents.length; i += 5) {
                 components.push(new MessageActionRow().addComponents(fullComponents.slice(i, i + 5)));
             }
-            let object = {
+            const object = {
                 embeds: [
                     new EmojiEmbed()
                         .setEmoji(this.emoji)
@@ -95,15 +95,15 @@
                 components: components,
                 ephemeral: true,
                 fetchReply: true
-            }
+            };
             let m;
             try {
                 if ( editOnly ) {
                     m = await this.interaction.editReply(object);
                 } else {
-                    m = await this.interaction.reply(object)
+                    m = await this.interaction.reply(object);
                 }
-            } catch { return { cancelled: true } }
+            } catch { return { cancelled: true }; }
             let component;
             try {
                 component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 300000});
@@ -112,17 +112,17 @@
             }
             if (component.customId === "yes") {
                 component.deferUpdate();
-                for (let [k, v] of Object.entries(this.customButtons)) {
-                    if (!v.active) continue
+                for (const v of Object.values(this.customButtons)) {
+                    if (!v.active) continue;
                     try { v.response = await v.onClick(); }
-                    catch (e) { console.log(e) }
-                };
+                    catch (e) { console.log(e); }
+                }
                 return { success: true, components: this.customButtons };
             } else if (component.customId === "no") {
                 component.deferUpdate();
                 return { success: false, components: this.customButtons };
             } else if (component.customId === "reason") {
-                await component.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Editing reason`).addComponents(
+                await component.showModal(new Discord.Modal().setCustomId("modal").setTitle("Editing reason").addComponents(
                     new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
                         .setCustomId("reason")
                         .setLabel("Reason")
@@ -132,7 +132,7 @@
                         .setPlaceholder("Spammed in #general")
                         .setValue(this.reason ? this.reason : "")
                     )
-                ))
+                ));
                 await this.interaction.editReply({
                     embeds: [new EmojiEmbed()
                         .setTitle(this.title)
@@ -148,10 +148,10 @@
                 });
                 let out;
                 try {
-                    out = await modalInteractionCollector(m, (m) => m.channel.id === this.interaction.channel.id, (m) => m.customId === "reason")
-                } catch (e) { return {} }
+                    out = await modalInteractionCollector(m, (m) => m.channel.id === this.interaction.channel.id, (m) => m.customId === "reason");
+                } catch (e) { return {}; }
                 if (out.fields) { return { newReason: out.fields.getTextInputValue("reason") ?? "" }; }
-                else { return { newReason: this.reason } }
+                else { return { newReason: this.reason }; }
             } else {
                 component.deferUpdate();
                 this.customButtons[component.customId].active = !this.customButtons[component.customId].active;
