diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 0eb8580..7e2902e 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -29,11 +29,15 @@
     const guild = interaction.guild!;
     const member = (interaction.options.getMember("user") ?? interaction.member) as Discord.GuildMember;
     await userAbout(guild, member, interaction);
-}
+};
 
-async function userAbout(guild: Discord.Guild, member: Discord.GuildMember, interaction: Discord.CommandInteraction | Discord.ContextMenuCommandInteraction) {
-    await member.user.fetch()
-    await member.fetch()
+async function userAbout(
+    guild: Discord.Guild,
+    member: Discord.GuildMember,
+    interaction: Discord.CommandInteraction | Discord.ContextMenuCommandInteraction
+) {
+    await member.user.fetch();
+    await member.fetch();
     await interaction.reply({
         embeds: LoadingEmbed,
         fetchReply: true,
@@ -59,10 +63,18 @@
     ) {
         flags.push("CLICKSDEVELOPER");
     }
-    if (member.user.flags) { member.user.flags.toArray().map((flag) => { flags.push(flag.toString()); }); }
-    if (member.user.bot) { flags.push("BOT"); }
+    if (member.user.flags) {
+        member.user.flags.toArray().map((flag) => {
+            flags.push(flag.toString());
+        });
+    }
+    if (member.user.bot) {
+        flags.push("BOT");
+    }
     // Check if they are boosting the server
-    if (member.premiumSince) { flags.push("BOOSTER"); }
+    if (member.premiumSince) {
+        flags.push("BOOSTER");
+    }
     const nameReplacements: Record<string, string> = {
         NUCLEUSDEVELOPER: "**Nucleus Developer**",
         CLICKSDEVELOPER: "Clicks Developer",
@@ -79,7 +91,8 @@
         Staff: "Discord Staff",
         VerifiedDeveloper: "Verified Bot Developer",
         ActiveDeveloper: "Active Developer",
-        Quarantined: "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
+        Quarantined:
+            "Quarantined [[What does this mean?]](https://support.discord.com/hc/en-us/articles/6461420677527)",
         Spammer: "Likely Spammer"
         // CertifiedModerator
         // VerifiedBot
@@ -139,24 +152,27 @@
                     .setStatus("Success")
                     .setEmoji("MEMBER.JOIN")
                     .setDescription(
-                        flags.map((flag) => {
-                            if (nameReplacements[flag]) {
-                                const emoji = getEmojiByName(`BADGES.${flag}`)
-                                if (emoji) return (emoji + " " + nameReplacements[flag] + "\n");
-                                else return nameReplacements[flag] + "\n";
-                            }
-                        }).join("") + "\n" +
-                        generateKeyValueList({
-                            member: renderUser(member.user),
-                            nickname: member.nickname ?? "*None set*",
-                            id: `\`${member.id}\``,
-                            "joined the server": renderDelta(member.joinedTimestamp!),
-                            "joined discord": renderDelta(member.user.createdTimestamp),
-                            "boost status": member.premiumSince
-                                ? `Started boosting ${renderDelta(member.premiumSinceTimestamp!)}`
-                                : "*Not boosting*",
-                            "join position": `${joinPos + 1}`
-                        })
+                        flags
+                            .map((flag) => {
+                                if (nameReplacements[flag]) {
+                                    const emoji = getEmojiByName(`BADGES.${flag}`);
+                                    if (emoji) return emoji + " " + nameReplacements[flag] + "\n";
+                                    else return nameReplacements[flag] + "\n";
+                                }
+                            })
+                            .join("") +
+                            "\n" +
+                            generateKeyValueList({
+                                member: renderUser(member.user),
+                                nickname: member.nickname ?? "*None set*",
+                                id: `\`${member.id}\``,
+                                "joined the server": renderDelta(member.joinedTimestamp!),
+                                "joined discord": renderDelta(member.user.createdTimestamp),
+                                "boost status": member.premiumSince
+                                    ? `Started boosting ${renderDelta(member.premiumSinceTimestamp!)}`
+                                    : "*Not boosting*",
+                                "join position": `${joinPos + 1}`
+                            })
                     )
                     .setThumbnail(member.user.displayAvatarURL())
             )
@@ -174,7 +190,10 @@
                             member: renderUser(member.user),
                             id: `\`${member.id}\``,
                             roles: `${member.roles.cache.size - 1}`
-                        }) + "\n" + (s.length > 0 ? s : "*None*") + "\n"
+                        }) +
+                            "\n" +
+                            (s.length > 0 ? s : "*None*") +
+                            "\n"
                     )
             )
             .setTitle("Roles")
@@ -199,7 +218,9 @@
             .setDescription("Key permissions the user has")
             .setPageId(2)
     ];
-    if (member.user.bannerURL() ) { embeds[0]!.embed.setImage(member.user.bannerURL()!); }
+    if (member.user.bannerURL()) {
+        embeds[0]!.embed.setImage(member.user.bannerURL()!);
+    }
     let page = 0;
     let timedOut = false;
     for (const embed of embeds) {
@@ -255,7 +276,13 @@
         try {
             i = await m.awaitMessageComponent({
                 time: 300000,
-                filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+                filter: (i) => {
+                    return (
+                        i.user.id === interaction.user.id &&
+                        i.channel!.id === interaction.channel!.id &&
+                        i.message.id === m.id
+                    );
+                }
             });
         } catch {
             timedOut = true;
@@ -281,8 +308,8 @@
         embeds: [em],
         components: []
     });
-};
+}
 
 export { command };
 export { callback };
-export { userAbout };
\ No newline at end of file
+export { userAbout };
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index da33f51..6804695 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -35,6 +35,5 @@
     });
 };
 
-
 export { command };
 export { callback };
diff --git a/src/commands/user/role.ts b/src/commands/user/role.ts
index 41820ac..74b6c41 100644
--- a/src/commands/user/role.ts
+++ b/src/commands/user/role.ts
@@ -1,17 +1,29 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction, GuildMember, Role, RoleSelectMenuBuilder, RoleSelectMenuInteraction, UserSelectMenuBuilder, UserSelectMenuInteraction } from "discord.js";
+import {
+    ActionRowBuilder,
+    APIMessageComponentEmoji,
+    ButtonBuilder,
+    ButtonInteraction,
+    ButtonStyle,
+    CommandInteraction,
+    GuildMember,
+    Role,
+    RoleSelectMenuBuilder,
+    RoleSelectMenuInteraction,
+    UserSelectMenuBuilder,
+    UserSelectMenuInteraction
+} from "discord.js";
 import type { SlashCommandSubcommandBuilder } from "discord.js";
 import client from "../../utils/client.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import { LoadingEmbed } from "../../utils/defaults.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
-import listToAndMore from "../../utils/listToAndMore.js"
+import listToAndMore from "../../utils/listToAndMore.js";
 
 const { renderUser } = client.logger;
 
 const canEdit = (role: Role, member: GuildMember, me: GuildMember): [string, boolean] => {
-    if(role.position >= me.roles.highest.position ||
-       role.position >= member.roles.highest.position
-    ) return [`~~<@&${role.id}>~~`, false];
+    if (role.position >= me.roles.highest.position || role.position >= member.roles.highest.position)
+        return [`~~<@&${role.id}>~~`, false];
     return [`<@&${role.id}>`, true];
 };
 
@@ -19,103 +31,116 @@
     builder
         .setName("role")
         .setDescription("Gives or removes a role from someone")
-        .addUserOption((option) => option.setName("user").setDescription("The user to give or remove the role from"))
+        .addUserOption((option) => option.setName("user").setDescription("The user to give or remove the role from"));
 
 const callback = async (interaction: CommandInteraction): Promise<unknown> => {
     const m = await interaction.reply({ embeds: LoadingEmbed, fetchReply: true, ephemeral: true });
 
     let member = interaction.options.getMember("user") as GuildMember | null;
 
-    if(!member) {
+    if (!member) {
         const memberEmbed = new EmojiEmbed()
             .setTitle("Role")
             .setDescription(`Please choose a member to edit the roles of.`)
             .setEmoji("GUILD.ROLES.CREATE")
             .setStatus("Success");
         const memberChooser = new ActionRowBuilder<UserSelectMenuBuilder>().addComponents(
-            new UserSelectMenuBuilder()
-                .setCustomId("memberChooser")
-                .setPlaceholder("Select a member")
+            new UserSelectMenuBuilder().setCustomId("memberChooser").setPlaceholder("Select a member")
         );
-        await interaction.editReply({embeds: [memberEmbed], components: [memberChooser]});
+        await interaction.editReply({ embeds: [memberEmbed], components: [memberChooser] });
 
-        const filter = (i: UserSelectMenuInteraction) => i.customId === "memberChooser" && i.user.id === interaction.user.id;
+        const filter = (i: UserSelectMenuInteraction) =>
+            i.customId === "memberChooser" && i.user.id === interaction.user.id;
 
         let i: UserSelectMenuInteraction | null;
         try {
-            i = await m.awaitMessageComponent<5>({ filter, time: 300000});
+            i = await m.awaitMessageComponent<5>({ filter, time: 300000 });
         } catch (e) {
             return;
         }
 
         memberEmbed.setDescription(`Editing roles for ${renderUser(i.values[0]!)}`);
         await i.deferUpdate();
-        await interaction.editReply({ embeds: LoadingEmbed, components: [] })
+        await interaction.editReply({ embeds: LoadingEmbed, components: [] });
         member = await interaction.guild?.members.fetch(i.values[0]!)!;
-
     }
 
     let closed = false;
     let rolesToChange: string[] = [];
-    const roleAdd = new ActionRowBuilder<RoleSelectMenuBuilder>()
-        .addComponents(
-            new RoleSelectMenuBuilder()
-                .setCustomId("roleAdd")
-                .setPlaceholder("Select a role to add")
-                .setMaxValues(25)
-        );
+    const roleAdd = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+        new RoleSelectMenuBuilder().setCustomId("roleAdd").setPlaceholder("Select a role to add").setMaxValues(25)
+    );
 
     do {
-
-        const removing = rolesToChange.filter((r) => member!.roles.cache.has(r)).map((r) => canEdit(interaction.guild?.roles.cache.get(r)!, interaction.member as GuildMember, interaction.guild?.members.me!)[0])
-        const adding = rolesToChange.filter((r) => !member!.roles.cache.has(r)).map((r) => canEdit(interaction.guild?.roles.cache.get(r)!, interaction.member as GuildMember, interaction.guild?.members.me!)[0])
-        const embed = new EmojiEmbed()
-        .setTitle("Role")
-        .setDescription(
-            `${getEmojiByName("ICONS.EDIT")} Editing roles for <@${member.id}>\n\n` +
-            `Adding:\n` +
-            `${listToAndMore(adding.length > 0 ? adding : ["None"], 5)}\n` +
-            `Removing:\n` +
-            `${listToAndMore(removing.length > 0 ? removing : ["None"], 5)}\n`
-        )
-        .setEmoji("GUILD.ROLES.CREATE")
-        .setStatus("Success");
-
-        const buttons = new ActionRowBuilder<ButtonBuilder>()
-            .addComponents(
-                new ButtonBuilder()
-                    .setCustomId("roleSave")
-                    .setLabel("Apply")
-                    .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
-                    .setStyle(ButtonStyle.Success),
-                new ButtonBuilder()
-                    .setCustomId("roleDiscard")
-                    .setLabel("Reset")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji)
-                    .setStyle(ButtonStyle.Danger)
+        const removing = rolesToChange
+            .filter((r) => member!.roles.cache.has(r))
+            .map(
+                (r) =>
+                    canEdit(
+                        interaction.guild?.roles.cache.get(r)!,
+                        interaction.member as GuildMember,
+                        interaction.guild?.members.me!
+                    )[0]
             );
+        const adding = rolesToChange
+            .filter((r) => !member!.roles.cache.has(r))
+            .map(
+                (r) =>
+                    canEdit(
+                        interaction.guild?.roles.cache.get(r)!,
+                        interaction.member as GuildMember,
+                        interaction.guild?.members.me!
+                    )[0]
+            );
+        const embed = new EmojiEmbed()
+            .setTitle("Role")
+            .setDescription(
+                `${getEmojiByName("ICONS.EDIT")} Editing roles for <@${member.id}>\n\n` +
+                    `Adding:\n` +
+                    `${listToAndMore(adding.length > 0 ? adding : ["None"], 5)}\n` +
+                    `Removing:\n` +
+                    `${listToAndMore(removing.length > 0 ? removing : ["None"], 5)}\n`
+            )
+            .setEmoji("GUILD.ROLES.CREATE")
+            .setStatus("Success");
+
+        const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+            new ButtonBuilder()
+                .setCustomId("roleSave")
+                .setLabel("Apply")
+                .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+                .setStyle(ButtonStyle.Success),
+            new ButtonBuilder()
+                .setCustomId("roleDiscard")
+                .setLabel("Reset")
+                .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji)
+                .setStyle(ButtonStyle.Danger)
+        );
 
         await interaction.editReply({ embeds: [embed], components: [roleAdd, buttons] });
 
         let i: RoleSelectMenuInteraction | ButtonInteraction | null;
         try {
-            i = await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 }) as RoleSelectMenuInteraction | ButtonInteraction;
+            i = (await m.awaitMessageComponent({ filter: (i) => i.user.id === interaction.user.id, time: 300000 })) as
+                | RoleSelectMenuInteraction
+                | ButtonInteraction;
         } catch (e) {
             closed = true;
             continue;
         }
 
         i.deferUpdate();
-        if(i.isButton()) {
-            switch(i.customId) {
+        if (i.isButton()) {
+            switch (i.customId) {
                 case "roleSave": {
                     const roles = rolesToChange.map((r) => interaction.guild?.roles.cache.get(r)!);
                     await interaction.editReply({ embeds: LoadingEmbed, components: [] });
                     const rolesToAdd: Role[] = [];
                     const rolesToRemove: Role[] = [];
-                    for(const role of roles) {
-                        if(!canEdit(role, interaction.member as GuildMember, interaction.guild?.members.me!)[1]) continue;
-                        if(member.roles.cache.has(role.id)) {
+                    for (const role of roles) {
+                        if (!canEdit(role, interaction.member as GuildMember, interaction.guild?.members.me!)[1])
+                            continue;
+                        if (member.roles.cache.has(role.id)) {
                             rolesToRemove.push(role);
                         } else {
                             rolesToAdd.push(role);
@@ -135,9 +160,7 @@
         } else {
             rolesToChange = i.values;
         }
-
     } while (!closed);
-
 };
 
 const check = (interaction: CommandInteraction, partial: boolean = false) => {
@@ -145,7 +168,7 @@
     // Check if the user has manage_roles permission
     if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
     if (partial) return true;
-    if (!interaction.guild) return
+    if (!interaction.guild) return;
     const me = interaction.guild.members.me!;
     // Check if Nucleus has permission to role
     if (!me.permissions.has("ManageRoles")) return "I do not have the *Manage Roles* permission";
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index c7f441f..19b9da2 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,5 +1,17 @@
 import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, GuildMember, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle, APIMessageComponentEmoji, StringSelectMenuBuilder, MessageComponentInteraction, StringSelectMenuInteraction, StringSelectMenuOptionBuilder } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    GuildMember,
+    Message,
+    ActionRowBuilder,
+    ButtonBuilder,
+    ButtonStyle,
+    APIMessageComponentEmoji,
+    StringSelectMenuBuilder,
+    MessageComponentInteraction,
+    StringSelectMenuInteraction,
+    StringSelectMenuOptionBuilder
+} from "discord.js";
 import type { SlashCommandSubcommandBuilder } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -14,7 +26,7 @@
         .addUserOption((option) => option.setName("user").setDescription("The user to manage").setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<unknown> => {
-    const { renderUser, renderRole} = client.logger;
+    const { renderUser, renderRole } = client.logger;
     const member = interaction.options.getMember("user") as GuildMember;
     const guild = interaction.guild;
     if (!guild) return;
@@ -63,13 +75,15 @@
         for (const role of data.track) {
             const disabled: boolean =
                 roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position && !managed;
-            allowed.push(!disabled)
+            allowed.push(!disabled);
         }
-        generated += "\n" + createVerticalTrack(
-            data.track.map((role) => renderRole(roles.get(role)!)),
-            data.track.map((role) => memberRoles.cache.has(role)),
-            allowed.map((allow) => !allow)
-        );
+        generated +=
+            "\n" +
+            createVerticalTrack(
+                data.track.map((role) => renderRole(roles.get(role)!)),
+                data.track.map((role) => memberRoles.cache.has(role)),
+                allowed.map((allow) => !allow)
+            );
         const selected = [];
         for (const position of data.track) {
             if (memberRoles.cache.has(position)) selected.push(position);
@@ -117,7 +131,9 @@
             ],
             components: [new ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>().addComponents(dropdown)]
                 .concat(
-                    conflict && conflictDropdown.length ? [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(conflictDropdown)] : []
+                    conflict && conflictDropdown.length
+                        ? [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(conflictDropdown)]
+                        : []
                 )
                 .concat([
                     new ActionRowBuilder<ButtonBuilder>().addComponents([
@@ -150,7 +166,13 @@
         try {
             component = await m.awaitMessageComponent({
                 time: 300000,
-                filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id }
+                filter: (i) => {
+                    return (
+                        i.user.id === interaction.user.id &&
+                        i.channel!.id === interaction.channel!.id &&
+                        i.message.id === m.id
+                    );
+                }
             });
         } catch (e) {
             timedOut = true;
@@ -158,7 +180,9 @@
         }
         component.deferUpdate();
         if (component.customId === "conflict") {
-            const rolesToRemove = selected.filter((role) => role !== (component as StringSelectMenuInteraction).values[0]);
+            const rolesToRemove = selected.filter(
+                (role) => role !== (component as StringSelectMenuInteraction).values[0]
+            );
             await member.roles.remove(rolesToRemove);
         } else if (component.customId === "promote") {
             if (
@@ -196,7 +220,7 @@
     if (member.id === interaction.guild!.ownerId) return true;
     // Check if the user can manage any of the tracks
     let managed = false;
-    const memberRoles = member.roles.cache.map((r) => r.id)
+    const memberRoles = member.roles.cache.map((r) => r.id);
     for (const element of tracks) {
         if (!element.manageableBy.length) continue;
         if (!element.manageableBy.some((role: string) => memberRoles.includes(role))) continue;
