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) => {
