diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index ede84b3..5f096ae 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,6 +1,18 @@
 import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, SelectMenuInteraction } from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import Discord, {
+    CommandInteraction,
+    GuildMember,
+    Message,
+    MessageActionRow,
+    MessageActionRowComponent,
+    MessageButton,
+    MessageComponentInteraction,
+    SelectMenuInteraction
+} from "discord.js";
+import {
+    SelectMenuOption,
+    SlashCommandSubcommandBuilder
+} from "@discordjs/builders";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import generateKeyValueList from "../../utils/generateKeyValueList.js";
@@ -11,218 +23,320 @@
     builder
         .setName("about")
         .setDescription("Shows info about a user")
-        .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"));
-
+        .addUserOption((option) =>
+            option
+                .setName("user")
+                .setDescription(
+                    "The user to get info about | Default: Yourself"
+                )
+        );
 
 class Embed {
     embed: Discord.MessageEmbed;
     title: string;
     description = "";
     pageId = 0;
-    setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
-    setTitle(title: string) { this.title = title; return this; }
-    setDescription(description: string) { this.description = description; return this; }
-    setPageId(pageId: number) { this.pageId = pageId; return this; }
+    setEmbed(embed: Discord.MessageEmbed) {
+        this.embed = embed;
+        return this;
+    }
+    setTitle(title: string) {
+        this.title = title;
+        return this;
+    }
+    setDescription(description: string) {
+        this.description = description;
+        return this;
+    }
+    setPageId(pageId: number) {
+        this.pageId = pageId;
+        return this;
+    }
 }
 
-
 const callback = async (interaction: CommandInteraction): Promise<void> => {
     const { renderUser, renderDelta } = client.logger;
-    const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+    const member = (interaction.options.getMember("user") ||
+        interaction.member) as Discord.GuildMember;
     const flags: string[] = [];
-    if ([
-        "438733159748599813", // Pinea
-        "317731855317336067", // Mini
-        "261900651230003201", // Coded
-        "511655498676699136" // Zan
-    ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER"); }
-    if ((await client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter((m: GuildMember) => m.roles.cache.has("760896837866749972"))?.map((m: GuildMember) => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER"); }
-    member.user.flags.toArray().map(flag => {
+    if (
+        [
+            "438733159748599813", // Pinea
+            "317731855317336067", // Mini
+            "261900651230003201", // Coded
+            "511655498676699136" // Zan
+        ].includes(member.user.id)
+    ) {
+        flags.push("NUCLEUSDEVELOPER");
+    }
+    if (
+        (await client.guilds.cache.get("684492926528651336")?.members.fetch())
+            ?.filter((m: GuildMember) =>
+                m.roles.cache.has("760896837866749972")
+            )
+            ?.map((m: GuildMember) => m.id)
+            .includes(member.user.id)
+    ) {
+        flags.push("CLICKSDEVELOPER");
+    }
+    member.user.flags.toArray().map((flag) => {
         flags.push(flag.toString());
     });
-    if (member.user.bot === true) { flags.push("BOT"); }
+    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 = {
-        "NUCLEUSDEVELOPER": "**Nucleus Developer**",
-        "CLICKSDEVELOPER": "Clicks Developer",
-        "HOUSE_BRAVERY": "Hypesquad Bravery",
-        "HOUSE_BRILLIANCE": "Hypesquad Brilliance",
-        "HOUSE_BALANCE": "Hypesquad Balance",
-        "HYPESQUAD_EVENTS": "Hypesquad Events",
-        "EARLY_SUPPORTER": "Early Supporter",
-        "BUGHUNTER_LEVEL_1": "Bug Hunter Level 1",
-        "BUGHUNTER_LEVEL_2": "Bug Hunter Level 2",
-        "PARTNERED_SERVER_OWNER": "Partnered Server Owner",
-        "DISCORD_EMPLOYEE": "Discord Staff",
-        "EARLY_VERIFIED_BOT_DEVELOPER": "Verified Bot Developer",
-        "BOT": "Bot",
-        "BOOSTER": "Server Booster"
+        NUCLEUSDEVELOPER: "**Nucleus Developer**",
+        CLICKSDEVELOPER: "Clicks Developer",
+        HOUSE_BRAVERY: "Hypesquad Bravery",
+        HOUSE_BRILLIANCE: "Hypesquad Brilliance",
+        HOUSE_BALANCE: "Hypesquad Balance",
+        HYPESQUAD_EVENTS: "Hypesquad Events",
+        EARLY_SUPPORTER: "Early Supporter",
+        BUGHUNTER_LEVEL_1: "Bug Hunter Level 1",
+        BUGHUNTER_LEVEL_2: "Bug Hunter Level 2",
+        PARTNERED_SERVER_OWNER: "Partnered Server Owner",
+        DISCORD_EMPLOYEE: "Discord Staff",
+        EARLY_VERIFIED_BOT_DEVELOPER: "Verified Bot Developer",
+        BOT: "Bot",
+        BOOSTER: "Server Booster"
     };
     const members = await interaction.guild.members.fetch();
     const membersArray = [...members.values()];
     membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp);
-    const joinPos = membersArray.findIndex(m => m.id === member.user.id);
+    const joinPos = membersArray.findIndex((m) => m.id === member.user.id);
 
-    const roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort();
+    const roles = member.roles.cache
+        .filter((r) => r.id !== interaction.guild.id)
+        .sort();
     let s = "";
     let count = 0;
     let ended = false;
-    roles.map(item => {
+    roles.map((item) => {
         if (ended) return;
         const string = `<@&${item.id}>, `;
-        if(s.length + string.length > 1000) {
+        if (s.length + string.length > 1000) {
             ended = true;
             s += `and ${roles.size - count} more`;
             return;
         }
-        count ++;
+        count++;
         s += string;
     });
-    if(s.length > 0 && !ended) s = s.slice(0, -2);
+    if (s.length > 0 && !ended) s = s.slice(0, -2);
 
     let perms = "";
     const permsArray = {
-        "ADMINISTRATOR": "Administrator",
-        "MANAGE_GUILD": "Manage Server",
-        "MANAGE_ROLES": "Manage Roles",
-        "MANAGE_CHANNELS": "Manage Channels",
-        "KICK_MEMBERS": "Kick Members",
-        "BAN_MEMBERS": "Ban Members",
-        "MODERATE_MEMBERS": "Moderate Members",
-        "MANAGE_NICKNAMES": "Manage Nicknames",
-        "MANAGE_WEBHOOKS": "Manage Webhooks",
-        "MANAGE_MESSAGES": "Manage Messages",
-        "VIEW_AUDIT_LOG": "View Audit Log",
-        "MENTION_EVERYONE": "Mention Everyone"
+        ADMINISTRATOR: "Administrator",
+        MANAGE_GUILD: "Manage Server",
+        MANAGE_ROLES: "Manage Roles",
+        MANAGE_CHANNELS: "Manage Channels",
+        KICK_MEMBERS: "Kick Members",
+        BAN_MEMBERS: "Ban Members",
+        MODERATE_MEMBERS: "Moderate Members",
+        MANAGE_NICKNAMES: "Manage Nicknames",
+        MANAGE_WEBHOOKS: "Manage Webhooks",
+        MANAGE_MESSAGES: "Manage Messages",
+        VIEW_AUDIT_LOG: "View Audit Log",
+        MENTION_EVERYONE: "Mention Everyone"
     };
-    Object.keys(permsArray).map(perm => {
-        const hasPerm = member.permissions.has(perm as Discord.PermissionString);
-        perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`;
+    Object.keys(permsArray).map((perm) => {
+        const hasPerm = member.permissions.has(
+            perm as Discord.PermissionString
+        );
+        perms += `${getEmojiByName(
+            "CONTROL." + (hasPerm ? "TICK" : "CROSS")
+        )} ${permsArray[perm]}\n`;
     });
 
     let selectPaneOpen = false;
 
     const embeds = [
         new Embed()
-            .setEmbed(new EmojiEmbed()
-                .setTitle("User Info: General")
-                .setStatus("Success")
-                .setEmoji("MEMBER.JOIN")
-                .setDescription(
-                    flags.map(flag => {
-                        if (nameReplacements[flag]) {
-                            return getEmojiByName(`BADGES.${flag}`) + " " + nameReplacements[flag];
-                        }
-                    }).join("\n") + "\n\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({dynamic: true}))
-                .setImage((await member.user.fetch()).bannerURL({format: "gif"}))
-            ).setTitle("General").setDescription("General information about the user").setPageId(0),
+            .setEmbed(
+                new EmojiEmbed()
+                    .setTitle("User Info: General")
+                    .setStatus("Success")
+                    .setEmoji("MEMBER.JOIN")
+                    .setDescription(
+                        flags
+                            .map((flag) => {
+                                if (nameReplacements[flag]) {
+                                    return (
+                                        getEmojiByName(`BADGES.${flag}`) +
+                                        " " +
+                                        nameReplacements[flag]
+                                    );
+                                }
+                            })
+                            .join("\n") +
+                            "\n\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({ dynamic: true })
+                    )
+                    .setImage(
+                        (await member.user.fetch()).bannerURL({ format: "gif" })
+                    )
+            )
+            .setTitle("General")
+            .setDescription("General information about the user")
+            .setPageId(0),
         new Embed()
-            .setEmbed(new EmojiEmbed()
-                .setTitle("User Info: Roles")
-                .setStatus("Success")
-                .setEmoji("GUILD.ROLES.CREATE")
-                .setDescription(
-                    generateKeyValueList({
-                        "member": renderUser(member.user),
-                        "id": `\`${member.id}\``,
-                        "roles": `${member.roles.cache.size - 1}`
-                    }) + "\n" +
-                    (s.length > 0 ? s : "*None*") + "\n"
-                )
-                .setThumbnail(member.user.displayAvatarURL({dynamic: true}))
-            ).setTitle("Roles").setDescription("Roles the user has").setPageId(1),
+            .setEmbed(
+                new EmojiEmbed()
+                    .setTitle("User Info: Roles")
+                    .setStatus("Success")
+                    .setEmoji("GUILD.ROLES.CREATE")
+                    .setDescription(
+                        generateKeyValueList({
+                            member: renderUser(member.user),
+                            id: `\`${member.id}\``,
+                            roles: `${member.roles.cache.size - 1}`
+                        }) +
+                            "\n" +
+                            (s.length > 0 ? s : "*None*") +
+                            "\n"
+                    )
+                    .setThumbnail(
+                        member.user.displayAvatarURL({ dynamic: true })
+                    )
+            )
+            .setTitle("Roles")
+            .setDescription("Roles the user has")
+            .setPageId(1),
         new Embed()
-            .setEmbed(new EmojiEmbed()
-                .setTitle("User Info: Key Permissions")
-                .setStatus("Success")
-                .setEmoji("GUILD.ROLES.CREATE")
-                .setDescription(
-                    generateKeyValueList({
-                        "member": renderUser(member.user),
-                        "id": `\`${member.id}\``
-                    }) + "\n" + perms
-                )
-                .setThumbnail(member.user.displayAvatarURL({dynamic: true}))
-            ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2)
+            .setEmbed(
+                new EmojiEmbed()
+                    .setTitle("User Info: Key Permissions")
+                    .setStatus("Success")
+                    .setEmoji("GUILD.ROLES.CREATE")
+                    .setDescription(
+                        generateKeyValueList({
+                            member: renderUser(member.user),
+                            id: `\`${member.id}\``
+                        }) +
+                            "\n" +
+                            perms
+                    )
+                    .setThumbnail(
+                        member.user.displayAvatarURL({ dynamic: true })
+                    )
+            )
+            .setTitle("Key Permissions")
+            .setDescription("Key permissions the user has")
+            .setPageId(2)
     ];
-    const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true}) as Message;
+    const m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        fetchReply: true,
+        ephemeral: true
+    })) as Message;
     let page = 0;
     let breakReason = "";
     while (true) {
         const em = new Discord.MessageEmbed(embeds[page].embed);
-        em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page));
+        em.setDescription(
+            em.description + "\n" + createPageIndicator(embeds.length, page)
+        );
         let selectPane = [];
 
         if (selectPaneOpen) {
             const options = [];
-            embeds.forEach(embed => {
-                options.push(new SelectMenuOption({
-                    label: embed.title,
-                    value: embed.pageId.toString(),
-                    description: embed.description || ""
-                }));
+            embeds.forEach((embed) => {
+                options.push(
+                    new SelectMenuOption({
+                        label: embed.title,
+                        value: embed.pageId.toString(),
+                        description: embed.description || ""
+                    })
+                );
             });
-            selectPane = [new MessageActionRow().addComponents([
-                new Discord.MessageSelectMenu()
-                    .addOptions(options)
-                    .setCustomId("page")
-                    .setMaxValues(1)
-                    .setPlaceholder("Choose a page...")
-            ])];
+            selectPane = [
+                new MessageActionRow().addComponents([
+                    new Discord.MessageSelectMenu()
+                        .addOptions(options)
+                        .setCustomId("page")
+                        .setMaxValues(1)
+                        .setPlaceholder("Choose a page...")
+                ])
+            ];
         }
         await interaction.editReply({
             embeds: [em],
-            components: selectPane.concat([new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                    .setStyle("SECONDARY")
-                    .setCustomId("left")
-                    .setDisabled(page === 0),
-                new MessageButton()
-                    .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
-                    .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
-                    .setCustomId("select")
-                    .setDisabled(false),
-                new MessageButton()
-                    .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
-                    .setCustomId("right")
-                    .setStyle("SECONDARY")
-                    .setDisabled(page === embeds.length - 1),
-                new MessageButton()
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setCustomId("close")
-                    .setStyle("DANGER")
-            ])])
+            components: selectPane.concat([
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+                        .setStyle("SECONDARY")
+                        .setCustomId("left")
+                        .setDisabled(page === 0),
+                    new MessageButton()
+                        .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+                        .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
+                        .setCustomId("select")
+                        .setDisabled(false),
+                    new MessageButton()
+                        .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+                        .setCustomId("right")
+                        .setStyle("SECONDARY")
+                        .setDisabled(page === embeds.length - 1),
+                    new MessageButton()
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setCustomId("close")
+                        .setStyle("DANGER")
+                ])
+            ])
         });
         let i: MessageComponentInteraction;
         try {
-            i = await m.awaitMessageComponent({time: 300000});
-        } catch { breakReason = "Message timed out"; break; }
+            i = await m.awaitMessageComponent({ time: 300000 });
+        } catch {
+            breakReason = "Message timed out";
+            break;
+        }
         i.deferUpdate();
         if ((i.component as MessageActionRowComponent).customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
-        } else if ((i.component as MessageActionRowComponent).customId === "right") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "right"
+        ) {
             if (page < embeds.length - 1) page++;
             selectPaneOpen = false;
-        } else if ((i.component as MessageActionRowComponent).customId === "select") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "select"
+        ) {
             selectPaneOpen = !selectPaneOpen;
-        } else if ((i.component as MessageActionRowComponent).customId === "close") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "close"
+        ) {
             breakReason = "Message closed";
             break;
-        } else if ((i.component as MessageActionRowComponent).customId === "page") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "page"
+        ) {
             page = parseInt((i as SelectMenuInteraction).values[0]);
             selectPaneOpen = false;
         } else {
@@ -231,29 +345,40 @@
         }
     }
     const em = new Discord.MessageEmbed(embeds[page].embed);
-    em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page) + " | " + breakReason);
-    await interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
-        new MessageButton()
-            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-            .setStyle("SECONDARY")
-            .setCustomId("left")
-            .setDisabled(true),
-        new MessageButton()
-            .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
-            .setStyle("SECONDARY")
-            .setCustomId("select")
-            .setDisabled(true),
-        new MessageButton()
-            .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
-            .setCustomId("right")
-            .setStyle("SECONDARY")
-            .setDisabled(true),
-        new MessageButton()
-            .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-            .setCustomId("close")
-            .setStyle("DANGER")
-            .setDisabled(true)
-    ])]});
+    em.setDescription(
+        em.description +
+            "\n" +
+            createPageIndicator(embeds.length, page) +
+            " | " +
+            breakReason
+    );
+    await interaction.editReply({
+        embeds: [em],
+        components: [
+            new MessageActionRow().addComponents([
+                new MessageButton()
+                    .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+                    .setStyle("SECONDARY")
+                    .setCustomId("left")
+                    .setDisabled(true),
+                new MessageButton()
+                    .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
+                    .setStyle("SECONDARY")
+                    .setCustomId("select")
+                    .setDisabled(true),
+                new MessageButton()
+                    .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+                    .setCustomId("right")
+                    .setStyle("SECONDARY")
+                    .setDisabled(true),
+                new MessageButton()
+                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                    .setCustomId("close")
+                    .setStyle("DANGER")
+                    .setDisabled(true)
+            ])
+        ]
+    });
 };
 
 const check = () => {
