diff --git a/src/commands/help.ts b/src/commands/help.ts
index a040358..e34500f 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -87,8 +87,8 @@
                 `Select a command to get started${(interaction.member?.permissions as PermissionsBitField).has("ManageGuild") ? `, or run ${getCommandMentionByName("nucleus/guide")} for commands to set up your server` : ``}`  // FIXME
             )
         } else {
-            let currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/'));
-            let current = commands.find((command) => command.name === currentPath[0])!;
+            const currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/'));
+            const current = commands.find((command) => command.name === currentPath[0])!;
 
             let optionString = ``
             let options: (ApplicationCommandOption & {
@@ -97,16 +97,16 @@
             })[] = [];
             //options
             if(currentPath[1] !== "" && currentPath[1] !== "none" && currentPath[2] !== "" && currentPath[2] !== "none") {
-                let Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
-                let Op2 = Op.options!.find(option => option.name === currentPath[2])!
-                options = Op2.options || []
+                const Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
+                const Op2 = Op.options!.find(option => option.name === currentPath[2])!
+                options = Op2.options ?? []
             } else if(currentPath[1] !== "" && currentPath[1] !== "none") {
                 let Op = current.options.find(option => option.name === currentPath[1])!
                 if(Op.type === ApplicationCommandOptionType.SubcommandGroup) {
                     options = []
                 } else {
                     Op = Op as ApplicationCommandSubCommand
-                    options = Op.options || []
+                    options = Op.options ?? []
                 }
             } else {
                 options = current.options.filter(option => option.type !== ApplicationCommandOptionType.SubcommandGroup && option.type !== ApplicationCommandOptionType.Subcommand) || [];
@@ -117,7 +117,7 @@
             const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0]
             let allowedToRun = true;
             if(APICommand?.check) {
-                APICommand?.check(interaction as Interaction, true)
+                allowedToRun = await APICommand.check(interaction as Interaction, true)
             }
             embed.setDescription(
                 `${getEmojiByName(styles[currentPath[0]]!.emoji)} **${capitalize(currentData.name)}**\n> ${currentData.mention}\n\n` +
@@ -136,7 +136,7 @@
                         ...subcommandGroups.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[1] === option.name))
                     )
                 if(subcommandGroupRow.components[0]!.options.find((option) => option.data.default && option.data.value !== "none")) {
-                    let subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand) || [];
+                    const subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand) ?? [];
                     subcommandRow.components[0]!
                         .addOptions(
                             new StringSelectMenuOptionBuilder().setLabel("Select a subcommand").setValue("none").setDefault(currentPath[2] === "none"),
@@ -152,7 +152,7 @@
             }
         }
 
-        let cmps = [commandRow];
+        const cmps = [commandRow];
         if(subcommandGroupRow.components[0]!.options.length > 0) cmps.push(subcommandGroupRow);
         if(subcommandRow.components[0]!.options.length > 0) cmps.push(subcommandRow);
 
@@ -163,20 +163,23 @@
             i = await m.awaitMessageComponent<ComponentType.StringSelect>({filter: (newInteraction) => interaction.user.id === newInteraction.user.id,time: 300000})
         } catch (e) {
             closed = true;
-            break;
+            continue;
         }
         await i.deferUpdate();
-        let value = i.values[0]!;
+        const value = i.values[0]!;
         switch(i.customId) {
-            case "commandRow":
+            case "commandRow": {
                 currentPath = [value, "", ""];
                 break;
-            case "subcommandGroupRow":
+            }
+            case "subcommandGroupRow": {
                 currentPath = [currentPath[0], value , ""];
                 break;
-            case "subcommandRow":
+            }
+            case "subcommandRow": {
                 currentPath[2] = value;
                 break;
+            }
         }
 
     } while (!closed);
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index 9d2c2b1..2f20d2e 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -79,39 +79,37 @@
         } catch (e) {
             return;
         }
-        if (i) {
-            i.deferUpdate();
-            let guild = i.guild!;
-            if (count - appliesTo.length <= 0) {
-                interaction.editReply({
-                    embeds: [
-                        new EmojiEmbed()
-                            .setTitle("Premium")
-                            .setDescription(
-                                `You have already activated premium on the maximum amount of servers!` + firstDescription
-                            )
-                            .setEmoji("NUCLEUS.PREMIUMACTIVATE")
-                            .setStatus("Danger")
-                    ],
-                    components: []
-                });
-                closed = true;
-            } else {
-                client.database.premium.addPremium(interaction.user.id, guild.id);
-                interaction.editReply({
-                    embeds: [
-                        new EmojiEmbed()
-                            .setTitle("Premium")
-                            .setDescription(
-                                `You have activated premium on this server!` + firstDescription
-                            )
-                            .setEmoji("NUCLEUS.LOGO")
-                            .setStatus("Danger")
-                    ],
-                    components: []
-                });
-                closed = true;
-            }
+        i.deferUpdate();
+        const guild = i.guild!;
+        if (count - appliesTo.length <= 0) {
+            interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Premium")
+                        .setDescription(
+                            `You have already activated premium on the maximum amount of servers!` + firstDescription
+                        )
+                        .setEmoji("NUCLEUS.PREMIUMACTIVATE")
+                        .setStatus("Danger")
+                ],
+                components: []
+            });
+            closed = true;
+        } else {
+            client.database.premium.addPremium(interaction.user.id, guild.id);
+            interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Premium")
+                        .setDescription(
+                            `You have activated premium on this server!` + firstDescription
+                        )
+                        .setEmoji("NUCLEUS.LOGO")
+                        .setStatus("Danger")
+                ],
+                components: []
+            });
+            closed = true;
         }
 
     } while (!closed);
diff --git a/src/commands/settings/automod.ts b/src/commands/settings/automod.ts
index 8e006b0..ab5e037 100644
--- a/src/commands/settings/automod.ts
+++ b/src/commands/settings/automod.ts
@@ -48,28 +48,30 @@
 const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message, ids: string[], type: "member" | "role" | "channel", title: string): Promise<string[]> => {
 
     const back = new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setCustomId("back").setLabel("Back").setStyle(ButtonStyle.Secondary).setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji));
-
     let closed;
     do {
         let render: string[] = []
         let mapped: string[] = [];
         let menu: UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder;
         switch(type) {
-            case "member":
+            case "member": {
                 menu = new UserSelectMenuBuilder().setCustomId("user").setPlaceholder("Select users").setMaxValues(25);
                 mapped = await Promise.all(ids.map(async (id) => { return (await client.users.fetch(id).then(user => user.tag)) || "Unknown User" }));
                 render = ids.map(id => client.logger.renderUser(id))
                 break;
-            case "role":
+            }
+            case "role": {
                 menu = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder("Select roles").setMaxValues(25);
-                mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name)) || "Unknown Role" }));
+                mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name ?? "Unknown Role"))}));
                 render = ids.map(id => client.logger.renderRole(id, interaction.guild!))
                 break;
-            case "channel":
+            }
+            case "channel": {
                 menu = new ChannelSelectMenuBuilder().setCustomId("channel").setPlaceholder("Select channels").setMaxValues(25);
-                mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name)) || "Unknown Channel" }));
+                mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name ?? "Unknown Role")) }));
                 render = ids.map(id => client.logger.renderChannel(id))
                 break;
+            }
         }
         const removeOptions = new ActionRowBuilder<StringSelectMenuBuilder>()
             .addComponents(
@@ -85,7 +87,7 @@
             .setEmoji(getEmojiByName("GUILD.SETTINGS.GREEN"))
             .setDescription(`Select ${type}s:\n\nCurrent:\n` + (render.length > 0 ? render.join("\n") : "None"))
             .setStatus("Success");
-        let components: ActionRowBuilder<
+        const components: ActionRowBuilder<
             StringSelectMenuBuilder |
             ButtonBuilder |
             ChannelSelectMenuBuilder |
@@ -102,7 +104,7 @@
             i = await m.awaitMessageComponent({filter: i => i.user.id === interaction.user.id, time: 300000});
         } catch(e) {
             closed = true;
-            break;
+            continue;
         }
 
         if(i.isButton()) {
@@ -176,15 +178,18 @@
         }
         await i.deferUpdate();
         switch(i.customId) {
-            case "back":
+            case "back": {
                 closed = true;
                 break;
-            case "nsfw":
+            }
+            case "nsfw": {
                 current.NSFW = !current.NSFW;
                 break;
-            case "size":
+            }
+            case "size": {
                 current.size = !current.size;
                 break;
+            }
         }
     } while(!closed);
     return current;
@@ -267,16 +272,18 @@
         if(i.isButton()) {
             await i.deferUpdate();
             switch(i.customId) {
-                case "back":
+                case "back": {
                     closed = true;
                     break;
-                case "enabled":
+                }
+                case "enabled": {
                     current.enabled = !current.enabled;
                     break;
+                }
             }
         } else {
             switch(i.values[0]) {
-                case "words":
+                case "words": {
                     await interaction.editReply({embeds: [new EmojiEmbed()
                         .setTitle("Word Filter")
                         .setDescription("Modal opened. If you can't see it, click back and try again.")
@@ -298,7 +305,7 @@
                                         .setCustomId("wordStrict")
                                         .setLabel("Strict Words")
                                         .setPlaceholder("Matches anywhere in the message, including surrounded by other characters")
-                                        .setValue(current.words.strict.join(", ") ?? "")
+                                        .setValue(current.words.strict.join(", "))
                                         .setStyle(TextInputStyle.Paragraph)
                                         .setRequired(false)
                                 ),
@@ -308,7 +315,7 @@
                                         .setCustomId("wordLoose")
                                         .setLabel("Loose Words")
                                         .setPlaceholder("Matches only if the word is by itself, surrounded by spaces or punctuation")
-                                        .setValue(current.words.loose.join(", ") ?? "")
+                                        .setValue(current.words.loose.join(", "))
                                         .setStyle(TextInputStyle.Paragraph)
                                         .setRequired(false)
                                 )
@@ -333,18 +340,22 @@
                     current.words.loose = out.fields.getTextInputValue("wordLoose")
                         .split(",").map(s => s.trim()).filter(s => s.length > 0);
                     break;
-                case "allowedUsers":
+                }
+                case "allowedUsers": {
                     await i.deferUpdate();
                     current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Word Filter");
                     break;
-                case "allowedRoles":
+                }
+                case "allowedRoles": {
                     await i.deferUpdate();
                     current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Word Filter");
                     break;
-                case "allowedChannels":
+                }
+                case "allowedChannels": {
                     await i.deferUpdate();
                     current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Word Filter");
                     break;
+                }
             }
         }
     } while(!closed);
@@ -420,25 +431,30 @@
         if(i.isButton()) {
             await i.deferUpdate();
             switch(i.customId) {
-                case "back":
+                case "back": {
                     closed = true;
                     break;
-                case "enabled":
+                }
+                case "enabled": {
                     current.enabled = !current.enabled;
                     break;
+                }
             }
         } else {
             await i.deferUpdate();
             switch(i.values[0]) {
-                case "users":
+                case "users": {
                     current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Invite Settings");
                     break;
-                case "roles":
+                }
+                case "roles": {
                     current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Invite Settings");
                     break;
-                case "channels":
+                }
+                case "channels": {
                     current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Invite Settings");
                     break;
+                }
             }
         }
 
@@ -557,21 +573,24 @@
         if(i.isButton()) {
             await i.deferUpdate();
             switch (i.customId) {
-                case "back":
+                case "back": {
                     closed = true;
                     break;
-                case "everyone":
+                }
+                case "everyone": {
                     current.everyone = !current.everyone;
                     break;
-                case "roles":
+                }
+                case "roles": {
                     current.roles = !current.roles;
                     break;
+                }
             }
         } else {
             switch (i.customId) {
-                case "toEdit":
+                case "toEdit": {
                     switch (i.values[0]) {
-                        case "mass":
+                        case "mass": {
                             await interaction.editReply({embeds: [new EmojiEmbed()
                                 .setTitle("Word Filter")
                                 .setDescription("Modal opened. If you can't see it, click back and try again.")
@@ -613,26 +632,33 @@
                             if(out.isButton()) break;
                             current.mass = parseInt(out.fields.getTextInputValue("mass"));
                             break;
-                        case "roles":
+                        }
+                        case "roles": {
                             await i.deferUpdate();
                             current.allowed.rolesToMention = await toSelectMenu(interaction, m, current.allowed.rolesToMention, "role", "Mention Settings");
                             break;
+                        }
                     }
                     break;
-                case "allowed":
+                }
+                case "allowed": {
                     await i.deferUpdate();
                     switch (i.values[0]) {
-                        case "users":
+                        case "users": {
                             current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings");
                             break;
-                        case "roles":
+                        }
+                        case "roles": {
                             current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings");
                             break;
-                        case "channels":
+                        }
+                        case "channels": {
                             current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Mention Settings");
                             break;
+                        }
                     }
                     break;
+                }
             }
         }
 
@@ -706,34 +732,38 @@
             i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 300000}) as StringSelectMenuInteraction | ButtonInteraction;
         } catch (e) {
             closed = true;
-            return;
+            continue;
         }
-        if(!i) return;
         if(i.isButton()) {
             await i.deferUpdate();
             await client.database.guilds.write(interaction.guild.id, {filters: config});
         } else {
             switch(i.values[0]) {
-                case "invites":
+                case "invites": {
                     await i.deferUpdate();
                     config.invite = await inviteMenu(i, m, config.invite);
                     break;
-                case "mentions":
+                }
+                case "mentions": {
                     await i.deferUpdate();
                     config.pings = await mentionMenu(i, m, config.pings);
                     break;
-                case "words":
+                }
+                case "words": {
                     await i.deferUpdate();
                     config.wordFilter = await wordMenu(i, m, config.wordFilter);
                     break;
-                case "malware":
+                }
+                case "malware": {
                     await i.deferUpdate();
                     config.malware = !config.malware;
                     break;
-                case "images":
-                    let next = await imageMenu(i, m, config.images);
-                    if(next) config.images = next;
+                }
+                case "images": {
+                    const next = await imageMenu(i, m, config.images);
+                    config.images = next;
                     break;
+                }
             }
         }
 
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 90b224d..635a1fd 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -41,7 +41,7 @@
 }
 
 const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message, currentObj: ObjectSchema[]) => {
-    let reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
+    const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
         .addComponents(
             new StringSelectMenuBuilder()
                 .setCustomId("reorder")
@@ -55,7 +55,7 @@
                     )
                 )
         );
-    let buttonRow = new ActionRowBuilder<ButtonBuilder>()
+    const buttonRow = new ActionRowBuilder<ButtonBuilder>()
         .addComponents(
             new ButtonBuilder()
                 .setCustomId("back")
@@ -85,7 +85,6 @@
     if(!out) return;
     out.deferUpdate();
     if (out.isButton()) return;
-    if(!out.values) return;
     const values = out.values;
 
     const newOrder: ObjectSchema[] = currentObj.map((_, i) => {
@@ -156,7 +155,6 @@
     }
     if(!out) return [name, description];
     if (out.isButton()) return [name, description];
-    if(!out.fields) return [name, description];
     name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
     description = out.fields.fields.find((f) => f.customId === "description")?.value ?? description;
     return [name, description]
@@ -223,19 +221,22 @@
             }
         } else if (i.isButton()) {
             switch (i.customId) {
-                case "back":
+                case "back": {
                     await i.deferUpdate();
                     back = true;
                     break;
-                case "edit":
-                    let [name, description] = await editNameDescription(i, interaction, m, data);
+                }
+                case "edit": {
+                    const [name, description] = await editNameDescription(i, interaction, m, data);
                     data.name = name ? name : data.name;
                     data.description = description ? description : data.description;
                     break;
-                case "addRole":
+                }
+                case "addRole": {
                     await i.deferUpdate();
                     data.options.push(await createRoleMenuOptionPage(interaction, m));
                     break;
+                }
             }
         }
 
@@ -247,9 +248,9 @@
 const createRoleMenuOptionPage = async (interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data?: {name: string; description: string | null; role: string}) => {
     const { renderRole} = client.logger;
     if (!data) data = {
-        name: "Role Menu Option",
+        name: "New role Menu Option",
         description: null,
-        role: "No role set"
+        role: ""
     };
     let back = false;
     const buttons = new ActionRowBuilder<ButtonBuilder>()
@@ -268,11 +269,11 @@
     do {
         const roleSelect = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder(data.role ? "Set role to" : "Set the role");
         const embed = new EmojiEmbed()
-            .setTitle(`${data.name ?? "New Role Menu Option"}`)
+            .setTitle(`${data.name}`)
             .setStatus("Success")
             .setDescription(
                 `**Description:**\n> ${data.description ?? "No description set"}\n\n` +
-                `**Role:** ${renderRole((await interaction.guild!.roles.fetch(data.role))!) ?? "No role set"}\n`
+                `**Role:** ${data.role ? renderRole((await interaction.guild!.roles.fetch(data.role))!) : "No role set"}\n`
             )
 
         interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect), buttons]});
@@ -292,16 +293,18 @@
             }
         } else if (i.isButton()) {
             switch (i.customId) {
-                case "back":
+                case "back": {
                     await i.deferUpdate();
                     back = true;
                     break;
-                case "edit":
+                }
+                case "edit": {
                     await i.deferUpdate();
-                    let [name, description] = await editNameDescription(i, interaction, m, data as {name: string; description: string});
+                    const [name, description] = await editNameDescription(i, interaction, m, data as {name: string; description: string});
                     data.name = name ? name : data.name;
                     data.description = description ? description : data.description;
                     break;
+                }
             }
         }
     } while (!back);
@@ -409,54 +412,63 @@
             i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
         } catch (e) {
             closed = true;
-            break;
+            continue;
         }
 
         await i.deferUpdate();
         if (i.isButton()) {
             switch (i.customId) {
-                case "back":
+                case "back": {
                     page--;
                     break;
-                case "next":
+                }
+                case "next": {
                     page++;
                     break;
-                case "add":
-                    let newPage = await editRoleMenuPage(i, m)
+                }
+                case "add": {
+                    const newPage = await editRoleMenuPage(i, m)
                     if(!newPage) break;
                     currentObject.push();
                     page = currentObject.length - 1;
                     break;
-                case "reorder":
-                    let reordered = await reorderRoleMenuPages(interaction, m, currentObject);
+                }
+                case "reorder": {
+                    const reordered = await reorderRoleMenuPages(interaction, m, currentObject);
                     if(!reordered) break;
                     currentObject = reordered;
                     break;
-                case "save":
+                }
+                case "save": {
                     client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject});
                     modified = false;
                     break;
+                }
             }
         } else if (i.isStringSelectMenu()) {
             switch (i.customId) {
-                case "action":
+                case "action": {
                     switch(i.values[0]) {
-                        case "edit":
-                            let edited = await editRoleMenuPage(i, m, current!);
+                        case "edit": {
+                            const edited = await editRoleMenuPage(i, m, current!);
                             if(!edited) break;
                             currentObject[page] = edited;
                             modified = true;
                             break;
-                        case "delete":
+                        }
+                        case "delete": {
                             if(page === 0 && currentObject.keys.length - 1 > 0) page++;
                             else page--;
                             currentObject.splice(page, 1);
                             break;
+                        }
                     }
                     break;
-                case "page":
+                }
+                case "page": {
                     page = parseInt(i.values[0]!);
                     break;
+                }
             }
         }
 
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index dd4027d..f8a57b7 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -136,11 +136,12 @@
         }
         if (i.isButton()) {
             switch (i.customId) {
-                case "back":
+                case "back": {
                     await i.deferUpdate();
                     closed = true;
                     break;
-                case "save":
+                }
+                case "save": {
                     await i.deferUpdate();
                     if (newChannel) {
                         currentObject[newChannel] = {
@@ -150,7 +151,8 @@
                     }
                     closed = true;
                     break;
-                case "editName":
+                }
+                case "editName": {
                     await interaction.editReply({
                         embeds: [new EmojiEmbed()
                                     .setTitle("Stats Channel")
@@ -170,20 +172,21 @@
                     });
                     showModal(i, {name: newChannelName, enabled: newChannelEnabled})
 
-                    const out = await modalInteractionCollector(
+                    const out: Discord.ModalSubmitInteraction | ButtonInteraction| null = await modalInteractionCollector(
                         m,
                         (m) => m.channel!.id === interaction.channel!.id && m.user!.id === interaction.user!.id,
                         (i) => i.channel!.id === interaction.channel!.id && i.user!.id === interaction.user!.id && i.message!.id === m.id
-                    ) as Discord.ModalSubmitInteraction | null;
+                    );
                     if (!out) continue;
-                    if (!out.fields) continue;
                     if (out.isButton()) continue;
                     newChannelName = out.fields.getTextInputValue("text");
                     break;
-                case "toggleEnabled":
+                }
+                case "toggleEnabled": {
                     await i.deferUpdate();
                     newChannelEnabled = !newChannelEnabled;
                     break;
+                }
             }
         } else {
             await i.deferUpdate();
@@ -307,11 +310,12 @@
 
         if(i.isStringSelectMenu()) {
             switch(i.customId) {
-                case "page":
+                case "page": {
                     await i.deferUpdate();
                     page = Object.keys(currentObject).indexOf(i.values[0]!);
                     break;
-                case "action":
+                }
+                case "action": {
                     modified = true;
                     switch(i.values[0]!) {
                         case "edit": {
@@ -345,7 +349,6 @@
                                 continue;
                             }
                             if (!out) continue
-                            if (!out.fields) continue
                             if (out.isButton()) continue;
                             currentObject[Object.keys(currentObject)[page]!]!.name = out.fields.getTextInputValue("text");
                             break;
@@ -358,32 +361,37 @@
                         }
                         case "delete": {
                             await i.deferUpdate();
-                            delete currentObject[Object.keys(currentObject)[page]!];
+                            currentObject = Object.fromEntries(Object.entries(currentObject).filter(([k]) => k !== Object.keys(currentObject)[page]!));
                             page = Math.min(page, Object.keys(currentObject).length - 1);
                             modified = true;
                             break;
                         }
                     }
                     break;
+                }
             }
         } else {
             await i.deferUpdate();
             switch(i.customId) {
-                case "back":
+                case "back": {
                     page--;
                     break;
-                case "next":
+                }
+                case "next": {
                     page++;
                     break;
-                case "add":
+                }
+                case "add": {
                     currentObject = await addStatsChannel(interaction, m, currentObject);
                     page = Object.keys(currentObject).length - 1;
                     break;
-                case "save":
+                }
+                case "save": {
                     client.database.guilds.write(interaction.guild.id, {stats: currentObject});
                     singleNotify("statsChannelDeleted", interaction.guild.id, true);
                     modified = false;
                     break;
+                }
             }
         }
 
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 3c5746c..29e6ea4 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -723,7 +723,7 @@
                 data.customTypes.push(toAdd);
             }
         } else if ((i.component as ButtonComponent).customId === "switchToDefault") {
-          await i.deferUpdate();
+            await i.deferUpdate();
             await client.database.guilds.write(interaction.guild!.id, { "tickets.useCustom": false }, []);
             data.useCustom = false;
         } else if ((i.component as ButtonComponent).customId === "switchToCustom") {
diff --git a/src/commands/settings/tracks.ts b/src/commands/settings/tracks.ts
index 354a948..4e27d68 100644
--- a/src/commands/settings/tracks.ts
+++ b/src/commands/settings/tracks.ts
@@ -37,7 +37,7 @@
                         .setCustomId("name")
                         .setPlaceholder("Name here...") // TODO: Make better placeholder
                         .setStyle(TextInputStyle.Short)
-                        .setValue(name ?? "")
+                        .setValue(name)
                         .setRequired(true)
                 )
         )
@@ -74,14 +74,13 @@
     }
     if(!out) return name;
     if (out.isButton()) return name;
-    if(!out.fields) return name;
     name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
     return name
 
 }
 
 const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles: Collection<string, Role>, currentObj: string[]) => {
-    let reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
+    const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
         .addComponents(
             new StringSelectMenuBuilder()
                 .setCustomId("reorder")
@@ -95,7 +94,7 @@
                     )
                 )
         );
-    let buttonRow = new ActionRowBuilder<ButtonBuilder>()
+    const buttonRow = new ActionRowBuilder<ButtonBuilder>()
         .addComponents(
             new ButtonBuilder()
                 .setCustomId("back")
@@ -125,7 +124,6 @@
     if(!out) return;
     out.deferUpdate();
     if (out.isButton()) return;
-    if(!out.values) return;
     const values = out.values;
 
     const newOrder: string[] = currentObj.map((_, i) => {
@@ -204,7 +202,7 @@
                     .setEmoji(getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji)
         );
 
-        let allowed: boolean[] = [];
+        const allowed: boolean[] = [];
         for (const role of current.track) {
             const disabled: boolean =
                 roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position;
@@ -241,39 +239,46 @@
         if (out.isButton()) {
             out.deferUpdate();
             switch(out.customId) {
-                case "back":
+                case "back": {
                     closed = true;
                     break;
-                case "edit":
+                }
+                case "edit": {
                     current.name = (await editName(out, interaction, message, current.name))!;
                     break;
-                case "reorder":
+                }
+                case "reorder": {
                     current.track = (await reorderTracks(out, message, roles, current.track))!;
                     break;
-                case "retainPrevious":
+                }
+                case "retainPrevious": {
                     current.retainPrevious = !current.retainPrevious;
                     break;
-                case "nullable":
+                }
+                case "nullable": {
                     current.nullable = !current.nullable;
                     break;
+                }
             }
         } else if (out.isStringSelectMenu()) {
             out.deferUpdate();
             switch(out.customId) {
-                case "removeRole":
+                case "removeRole": {
                     const index = current.track.findIndex(v => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]);
                     current.track.splice(index, 1);
                     break;
+                }
             }
         } else {
             switch(out.customId) {
-                case "addRole":
+                case "addRole": {
                     const role = out.values![0]!;
                     if(!current.track.includes(role)) {
                         current.track.push(role);
                     }
                     out.reply({content: "That role is already on this track", ephemeral: true})
                     break;
+                }
             }
         }
 
@@ -381,54 +386,61 @@
             i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
         } catch (e) {
             closed = true;
-            break;
+            continue;
         }
 
         await i.deferUpdate();
         if (i.isButton()) {
             switch (i.customId) {
-                case "back":
+                case "back": {
                     page--;
                     break;
-                case "next":
+                }
+                case "next": {
                     page++;
                     break;
-                case "add":
-                    let newPage = await editTrack(i, m, roles)
+                }
+                case "add": {
+                    const newPage = await editTrack(i, m, roles)
                     if(!newPage) break;
                     tracks.push();
                     page = tracks.length - 1;
                     break;
-                case "save":
+                }
+                case "save": {
                     client.database.guilds.write(interaction.guild!.id, {tracks: tracks});
                     modified = false;
                     break;
+                }
             }
         } else if (i.isStringSelectMenu()) {
             switch (i.customId) {
-                case "action":
+                case "action": {
                     switch(i.values[0]) {
-                        case "edit":
-                            let edited = await editTrack(i, m, roles, current!);
+                        case "edit": {
+                            const edited = await editTrack(i, m, roles, current!);
                             if(!edited) break;
                             tracks[page] = edited;
                             modified = true;
                             break;
-                        case "delete":
+                        }
+                        case "delete": {
                             if(page === 0 && tracks.keys.length - 1 > 0) page++;
                             else page--;
                             tracks.splice(page, 1);
                             break;
+                        }
                     }
                     break;
-                case "page":
+                }
+                case "page": {
                     page = parseInt(i.values[0]!);
                     break;
+                }
             }
         }
 
     } while (!closed)
-
 }
 
 const check = (interaction: CommandInteraction, _partial: boolean = false) => {
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index b929d3d..cf713e6 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -17,10 +17,10 @@
 
 export async function testNSFW(link: string): Promise<NSFWSchema> {
     const [p, hash] = await saveAttachment(link);
-    let alreadyHaveCheck = await client.database.scanCache.read(hash)
+    const alreadyHaveCheck = await client.database.scanCache.read(hash)
     if(alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data };
     const data = new URLSearchParams();
-    let r = createReadStream(p)
+    const r = createReadStream(p)
     data.append("file", r.read(fs.statSync(p).size));
     const result = await fetch("https://unscan.p.rapidapi.com/", {
         method: "POST",
@@ -43,10 +43,10 @@
 
 export async function testMalware(link: string): Promise<MalwareSchema> {
     const [p, hash] = await saveAttachment(link);
-    let alreadyHaveCheck = await client.database.scanCache.read(hash)
+    const alreadyHaveCheck = await client.database.scanCache.read(hash)
     if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data };
     const data = new URLSearchParams();
-    let f = createReadStream(p);
+    const f = createReadStream(p);
     data.append("file", f.read(fs.statSync(p).size));
     const result = await fetch("https://unscan.p.rapidapi.com/malware", {
         method: "POST",
@@ -68,7 +68,7 @@
 }
 
 export async function testLink(link: string): Promise<{ safe: boolean; tags: string[] }> {
-    let alreadyHaveCheck = await client.database.scanCache.read(link)
+    const alreadyHaveCheck = await client.database.scanCache.read(link)
     if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data, tags: [] };
     const scanned: { safe?: boolean; tags?: string[] } = await fetch("https://unscan.p.rapidapi.com/link", {
         method: "POST",
diff --git a/src/utils/client.ts b/src/utils/client.ts
index 41cdbca..5286814 100644
--- a/src/utils/client.ts
+++ b/src/utils/client.ts
@@ -33,7 +33,7 @@
         check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean,
         autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
     } | undefined,{name: string, description: string}]> = {};
-    fetchedCommands: Collection<string, Discord.ApplicationCommand> = new Collection();
+    fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
     constructor(database: typeof NucleusClient.prototype.database) {
         super({ intents: [
             GatewayIntentBits.Guilds,
diff --git a/src/utils/commandRegistration/slashCommandBuilder.ts b/src/utils/commandRegistration/slashCommandBuilder.ts
index b215572..ef45875 100644
--- a/src/utils/commandRegistration/slashCommandBuilder.ts
+++ b/src/utils/commandRegistration/slashCommandBuilder.ts
@@ -32,7 +32,7 @@
         if (descriptionLocalizations) { subcommandGroup.setDescriptionLocalizations(descriptionLocalizations) }
 
         for (const subcommand of fetched.subcommands) {
-            let processedCommand = subcommand.command(new SlashCommandSubcommandBuilder());
+            const processedCommand = subcommand.command(new SlashCommandSubcommandBuilder());
             client.commands["commands/" + path + "/" + processedCommand.name] = [subcommand, { name: processedCommand.name, description: processedCommand.description }]
             subcommandGroup.addSubcommand(processedCommand);
         };
@@ -80,7 +80,7 @@
             command.addSubcommand(fetchedCommand);
         }
         for (const group of fetched.subcommandGroups) {
-            let processedCommand = group.command(new SlashCommandSubcommandGroupBuilder());
+            const processedCommand = group.command(new SlashCommandSubcommandGroupBuilder());
             client.commands[commandString! + "/" + processedCommand.name] = [undefined, { name: processedCommand.name, description: processedCommand.description }]
             command.addSubcommandGroup(processedCommand);
         };
diff --git a/src/utils/log.ts b/src/utils/log.ts
index c5c7e06..64062ac 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -10,7 +10,7 @@
 
 export const Logger = {
     renderUser(user: Discord.User | string) {
-        if (typeof user === "string") user = client.users.cache.get(user) as Discord.User;
+        if (typeof user === "string") user = client.users.cache.get(user)!;
         return `${user.username} [<@${user.id}>]`;
     },
     renderTime(t: number) {
@@ -34,7 +34,7 @@
         return `${channel.name} [<#${channel.id}>]`;
     },
     renderRole(role: Discord.Role | string, guild?: Discord.Guild | string) {
-        if (typeof role === "string") role = (typeof guild === "string" ? client.guilds.cache.get(guild) : guild)!.roles.cache.get(role) as Discord.Role;
+        if (typeof role === "string") role = (typeof guild === "string" ? client.guilds.cache.get(guild) : guild)!.roles.cache.get(role)!;
         return `${role.name} [<@&${role.id}>]`;
     },
     renderEmoji(emoji: Discord.GuildEmoji) {
