diff --git a/src/commands/settings/_meta.ts b/src/commands/settings/_meta.ts
index 63d726e..1241322 100644
--- a/src/commands/settings/_meta.ts
+++ b/src/commands/settings/_meta.ts
@@ -1,4 +1,4 @@
 const name = "settings";
 const description = "Change bot settings";
 
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 845e001..13cfa89 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,5 +1,10 @@
 import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    MessageActionRow,
+    MessageButton,
+    TextInputComponent
+} from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -12,133 +17,257 @@
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
         .setName("commands")
-        .setDescription("Links and text shown to a user after a moderator action is performed")
-        .addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"));
+        .setDescription(
+            "Links and text shown to a user after a moderator action is performed"
+        )
+        .addRoleOption((o) =>
+            o
+                .setName("role")
+                .setDescription("The role given when a member is muted")
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    });
     let m;
     let clicked = "";
     if (interaction.options.getRole("role")) {
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.ROLES.DELETE")
             .setTitle("Moderation Commands")
-            .setDescription(keyValueList({
-                role: `<@&${interaction.options.getRole("role").id}>`
-            }))
+            .setDescription(
+                keyValueList({
+                    role: `<@&${interaction.options.getRole("role").id}>`
+                })
+            )
             .setColor("Danger")
             .send(true);
-        if (confirmation.cancelled) return await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Moderation Commands")
-            .setDescription("No changes were made")
-            .setStatus("Success")
-            .setEmoji("GUILD.ROLES.CREATE")
-        ]});
+        if (confirmation.cancelled)
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Moderation Commands")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("GUILD.ROLES.CREATE")
+                ]
+            });
         if (confirmation.success) {
-            await client.database.guilds.write(interaction.guild.id, {["moderation.mute.role"]: interaction.options.getRole("role").id});
+            await client.database.guilds.write(interaction.guild.id, {
+                ["moderation.mute.role"]: interaction.options.getRole("role").id
+            });
         }
     }
     while (true) {
         const config = await client.database.guilds.read(interaction.guild.id);
         const moderation = config.getKey("moderation");
-        m = await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Moderation Commands")
-            .setEmoji("PUNISH.BAN.GREEN")
-            .setStatus("Success")
-            .setDescription(
-                "These links are shown below the message sent in a user's DM when they are punished.\n\n" +
-                "**Mute Role:** " + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
-            )
-        ], components: [new MessageActionRow().addComponents([
-            new MessageButton().setLabel("Warn").setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id")).setCustomId("warn").setStyle("SECONDARY"),
-            new MessageButton().setLabel("Mute").setEmoji(getEmojiByName("PUNISH.MUTE.YELLOW", "id")).setCustomId("mute").setStyle("SECONDARY"),
-            new MessageButton().setLabel("Nickname").setEmoji(getEmojiByName("PUNISH.NICKNAME.GREEN", "id")).setCustomId("nickname").setStyle("SECONDARY")
-        ]), new MessageActionRow().addComponents([
-            new MessageButton().setLabel("Kick").setEmoji(getEmojiByName("PUNISH.KICK.RED", "id")).setCustomId("kick").setStyle("SECONDARY"),
-            new MessageButton().setLabel("Softban").setEmoji(getEmojiByName("PUNISH.BAN.YELLOW", "id")).setCustomId("softban").setStyle("SECONDARY"),
-            new MessageButton().setLabel("Ban").setEmoji(getEmojiByName("PUNISH.BAN.RED", "id")).setCustomId("ban").setStyle("SECONDARY")
-        ]), new MessageActionRow().addComponents([
-            new MessageButton().setLabel(
-                clicked === "clearMuteRole" ? "Click again to confirm" : "Clear mute role"
-            ).setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setCustomId("clearMuteRole").setStyle("DANGER").setDisabled(!moderation.mute.role),
-            new MessageButton()
-                .setCustomId("timeout")
-                .setLabel("Mute timeout " + (moderation.mute.timeout ? "Enabled" : "Disabled"))
-                .setStyle(moderation.mute.timeout ? "SUCCESS" : "DANGER")
-                .setEmoji(getEmojiByName("CONTROL." + (moderation.mute.timeout ? "TICK" : "CROSS"), "id"))
-        ])]});
+        m = await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Moderation Commands")
+                    .setEmoji("PUNISH.BAN.GREEN")
+                    .setStatus("Success")
+                    .setDescription(
+                        "These links are shown below the message sent in a user's DM when they are punished.\n\n" +
+                            "**Mute Role:** " +
+                            (moderation.mute.role
+                                ? `<@&${moderation.mute.role}>`
+                                : "*None set*")
+                    )
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel("Warn")
+                        .setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id"))
+                        .setCustomId("warn")
+                        .setStyle("SECONDARY"),
+                    new MessageButton()
+                        .setLabel("Mute")
+                        .setEmoji(getEmojiByName("PUNISH.MUTE.YELLOW", "id"))
+                        .setCustomId("mute")
+                        .setStyle("SECONDARY"),
+                    new MessageButton()
+                        .setLabel("Nickname")
+                        .setEmoji(getEmojiByName("PUNISH.NICKNAME.GREEN", "id"))
+                        .setCustomId("nickname")
+                        .setStyle("SECONDARY")
+                ]),
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel("Kick")
+                        .setEmoji(getEmojiByName("PUNISH.KICK.RED", "id"))
+                        .setCustomId("kick")
+                        .setStyle("SECONDARY"),
+                    new MessageButton()
+                        .setLabel("Softban")
+                        .setEmoji(getEmojiByName("PUNISH.BAN.YELLOW", "id"))
+                        .setCustomId("softban")
+                        .setStyle("SECONDARY"),
+                    new MessageButton()
+                        .setLabel("Ban")
+                        .setEmoji(getEmojiByName("PUNISH.BAN.RED", "id"))
+                        .setCustomId("ban")
+                        .setStyle("SECONDARY")
+                ]),
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel(
+                            clicked === "clearMuteRole"
+                                ? "Click again to confirm"
+                                : "Clear mute role"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setCustomId("clearMuteRole")
+                        .setStyle("DANGER")
+                        .setDisabled(!moderation.mute.role),
+                    new MessageButton()
+                        .setCustomId("timeout")
+                        .setLabel(
+                            "Mute timeout " +
+                                (moderation.mute.timeout
+                                    ? "Enabled"
+                                    : "Disabled")
+                        )
+                        .setStyle(
+                            moderation.mute.timeout ? "SUCCESS" : "DANGER"
+                        )
+                        .setEmoji(
+                            getEmojiByName(
+                                "CONTROL." +
+                                    (moderation.mute.timeout
+                                        ? "TICK"
+                                        : "CROSS"),
+                                "id"
+                            )
+                        )
+                ])
+            ]
+        });
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { return; }
-        let chosen = moderation[i.customId] ?? {text: null, url: null};
+        } catch (e) {
+            return;
+        }
+        let chosen = moderation[i.customId] ?? { text: null, url: null };
         if (i.component.customId === "clearMuteRole") {
             i.deferUpdate();
             if (clicked === "clearMuteRole") {
-                await client.database.guilds.write(interaction.guild.id, {"moderation.mute.role": null });
-            } else { clicked = "clearMuteRole"; }
+                await client.database.guilds.write(interaction.guild.id, {
+                    "moderation.mute.role": null
+                });
+            } else {
+                clicked = "clearMuteRole";
+            }
             continue;
-        } else { clicked = ""; }
+        } else {
+            clicked = "";
+        }
         if (i.component.customId === "timeout") {
             await i.deferUpdate();
-            await client.database.guilds.write(interaction.guild.id, {"moderation.mute.timeout": !moderation.mute.timeout } );
+            await client.database.guilds.write(interaction.guild.id, {
+                "moderation.mute.timeout": !moderation.mute.timeout
+            });
             continue;
         } else if (i.customId) {
-            await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Options for ${i.customId}`).addComponents(
-                new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                    .setCustomId("name")
-                    .setLabel("Button text")
-                    .setMaxLength(100)
-                    .setRequired(false)
-                    .setStyle("SHORT")
-                    .setValue(chosen.text ?? "")
-                ),
-                new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                    .setCustomId("url")
-                    .setLabel("URL - Type {id} to insert the user's ID")
-                    .setMaxLength(2000)
-                    .setRequired(false)
-                    .setStyle("SHORT")
-                    .setValue(chosen.link ?? "")
-                )
-            ));
+            await i.showModal(
+                new Discord.Modal()
+                    .setCustomId("modal")
+                    .setTitle(`Options for ${i.customId}`)
+                    .addComponents(
+                        new MessageActionRow<TextInputComponent>().addComponents(
+                            new TextInputComponent()
+                                .setCustomId("name")
+                                .setLabel("Button text")
+                                .setMaxLength(100)
+                                .setRequired(false)
+                                .setStyle("SHORT")
+                                .setValue(chosen.text ?? "")
+                        ),
+                        new MessageActionRow<TextInputComponent>().addComponents(
+                            new TextInputComponent()
+                                .setCustomId("url")
+                                .setLabel(
+                                    "URL - Type {id} to insert the user's ID"
+                                )
+                                .setMaxLength(2000)
+                                .setRequired(false)
+                                .setStyle("SHORT")
+                                .setValue(chosen.link ?? "")
+                        )
+                    )
+            );
             await interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Moderation Links")
-                    .setDescription("Modal opened. If you can't see it, click back and try again.")
-                    .setStatus("Success")
-                    .setEmoji("GUILD.TICKET.OPEN")
-                ], components: [new MessageActionRow().addComponents([new MessageButton()
-                    .setLabel("Back")
-                    .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                    .setStyle("PRIMARY")
-                    .setCustomId("back")
-                ])]
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Moderation Links")
+                        .setDescription(
+                            "Modal opened. If you can't see it, click back and try again."
+                        )
+                        .setStatus("Success")
+                        .setEmoji("GUILD.TICKET.OPEN")
+                ],
+                components: [
+                    new MessageActionRow().addComponents([
+                        new MessageButton()
+                            .setLabel("Back")
+                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+                            .setStyle("PRIMARY")
+                            .setCustomId("back")
+                    ])
+                ]
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (_) => true);
-            } catch (e) { continue; }
+                out = await modalInteractionCollector(
+                    m,
+                    (m) => m.channel.id === interaction.channel.id,
+                    (_) => true
+                );
+            } catch (e) {
+                continue;
+            }
             if (out.fields) {
                 const buttonText = out.fields.getTextInputValue("name");
-                const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
+                const buttonLink = out.fields
+                    .getTextInputValue("url")
+                    .replace(/{id}/gi, "{id}");
                 const current = chosen;
-                if (current.text !== buttonText || current.link !== buttonLink) {
+                if (
+                    current.text !== buttonText ||
+                    current.link !== buttonLink
+                ) {
                     chosen = { text: buttonText, link: buttonLink };
-                    await client.database.guilds.write(interaction.guild.id, { ["moderation." + i.customId]: { text: buttonText, link: buttonLink }});
+                    await client.database.guilds.write(interaction.guild.id, {
+                        ["moderation." + i.customId]: {
+                            text: buttonText,
+                            link: buttonLink
+                        }
+                    });
                 }
-            } else { continue; }
+            } else {
+                continue;
+            }
         }
     }
 };
 
-
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/filters.ts b/src/commands/settings/filters.ts
index 7ee5b8d..3b0988e 100644
--- a/src/commands/settings/filters.ts
+++ b/src/commands/settings/filters.ts
@@ -2,20 +2,19 @@
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
-    builder
-        .setName("filter")
-        .setDescription("Setting for message filters");
+    builder.setName("filter").setDescription("Setting for message filters");
 
 const callback = async (_interaction: CommandInteraction): Promise<void> => {
     console.log("Filters");
 };
 
 const check = (interaction: CommandInteraction) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command";
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_MESSAGES"))
+        throw "You must have the *Manage Messages* permission to use this command";
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/logs/_meta.ts b/src/commands/settings/logs/_meta.ts
index f46987f..fadff33 100644
--- a/src/commands/settings/logs/_meta.ts
+++ b/src/commands/settings/logs/_meta.ts
@@ -1,4 +1,4 @@
 const name = "logs";
 const description = "Settings for logging";
 
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index cb96567..f37bd1a 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,6 +1,10 @@
 import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
 import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    MessageActionRow,
+    MessageButton
+} from "discord.js";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../../utils/confirmationMessage.js";
 import getEmojiByName from "../../../utils/getEmojiByName.js";
@@ -12,39 +16,59 @@
     builder
         .setName("attachments")
         .setDescription("Where attachments should be logged to (Premium only)")
-        .addChannelOption(option => option.setName("channel").setDescription("The channel to log attachments in").addChannelTypes([
-            ChannelType.GuildNews, ChannelType.GuildText
-        ]).setRequired(false));
+        .addChannelOption((option) =>
+            option
+                .setName("channel")
+                .setDescription("The channel to log attachments in")
+                .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+                .setRequired(false)
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message;
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    const m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    })) as Discord.Message;
     if (interaction.options.getChannel("channel")) {
         let channel;
         try {
             channel = interaction.options.getChannel("channel");
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("CHANNEL.TEXT.DELETE")
-                .setTitle("Attachment Log Channel")
-                .setDescription("The channel you provided is not a valid channel")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                        .setTitle("Attachment Log Channel")
+                        .setDescription(
+                            "The channel you provided is not a valid channel"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Attachment Log Channel")
-                .setDescription("You must choose a channel in this server")
-                .setStatus("Danger")
-                .setEmoji("CHANNEL.TEXT.DELETE")
-            ]});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Attachment Log Channel")
+                        .setDescription(
+                            "You must choose a channel in this server"
+                        )
+                        .setStatus("Danger")
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                ]
+            });
         }
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Attachment Log Channel")
             .setDescription(
                 "This will be the channel all attachments will be sent to.\n\n" +
-                `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
+                    `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
             )
             .setColor("Warning")
             .setInverted(true)
@@ -52,10 +76,13 @@
         if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"logging.attachments.channel": channel.id});
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                await client.database.guilds.write(interaction.guild.id, {
+                    "logging.attachments.channel": channel.id
+                });
+                const { log, NucleusColors, entry, renderUser, renderChannel } =
+                    client.logger;
                 const data = {
-                    meta:{
+                    meta: {
                         type: "attachmentChannelUpdate",
                         displayName: "Attachment Log Channel Updated",
                         calculateType: "nucleusSettingsUpdated",
@@ -64,8 +91,14 @@
                         timestamp: new Date().getTime()
                     },
                     list: {
-                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        memberId: entry(
+                            interaction.user.id,
+                            `\`${interaction.user.id}\``
+                        ),
+                        changedBy: entry(
+                            interaction.user.id,
+                            renderUser(interaction.user)
+                        ),
                         channel: entry(channel.id, renderChannel(channel))
                     },
                     hidden: {
@@ -74,75 +107,124 @@
                 };
                 log(data);
             } catch (e) {
-                return interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Attachment Log Channel")
-                    .setDescription("Something went wrong and the attachment log channel could not be set")
-                    .setStatus("Danger")
-                    .setEmoji("CHANNEL.TEXT.DELETE")
-                ], components: []});
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Attachment Log Channel")
+                            .setDescription(
+                                "Something went wrong and the attachment log channel could not be set"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                    ],
+                    components: []
+                });
             }
         } else {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Attachment Log Channel")
-                .setDescription("No changes were made")
-                .setStatus("Success")
-                .setEmoji("CHANNEL.TEXT.CREATE")
-            ], components: []});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Attachment Log Channel")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("CHANNEL.TEXT.CREATE")
+                ],
+                components: []
+            });
         }
     }
     let clicks = 0;
     const data = await client.database.guilds.read(interaction.guild.id);
     let channel = data.logging.staff.channel;
     while (true) {
-        await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Attachment Log Channel")
-            .setDescription(
-                channel ? `Your attachment log channel is currently set to <#${channel}>` : "This server does not have an attachment log channel" +
-                (client.database.premium.hasPremium(interaction.guild.id) ? "" : "\n\nThis server does not have premium, so this feature is disabled")
-            )
-            .setStatus("Success")
-            .setEmoji("CHANNEL.TEXT.CREATE")
-        ], components: [new MessageActionRow().addComponents([new MessageButton()
-            .setCustomId("clear")
-            .setLabel(clicks ? "Click again to confirm" : "Reset channel")
-            .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
-            .setStyle("DANGER")
-            .setDisabled(!channel)
-        ])]});
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Attachment Log Channel")
+                    .setDescription(
+                        channel
+                            ? `Your attachment log channel is currently set to <#${channel}>`
+                            : "This server does not have an attachment log channel" +
+                                  (client.database.premium.hasPremium(
+                                      interaction.guild.id
+                                  )
+                                      ? ""
+                                      : "\n\nThis server does not have premium, so this feature is disabled")
+                    )
+                    .setStatus("Success")
+                    .setEmoji("CHANNEL.TEXT.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setCustomId("clear")
+                        .setLabel(
+                            clicks ? "Click again to confirm" : "Reset channel"
+                        )
+                        .setEmoji(
+                            getEmojiByName(
+                                clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+                                "id"
+                            )
+                        )
+                        .setStyle("DANGER")
+                        .setDisabled(!channel)
+                ])
+            ]
+        });
         let i;
         try {
-            i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break; }
+            i = await m.awaitMessageComponent({ time: 300000 });
+        } catch (e) {
+            break;
+        }
         i.deferUpdate();
         if (i.component.customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "logging.announcements.channel"
+                ]);
                 channel = undefined;
             }
         } else {
             break;
         }
     }
-    await interaction.editReply({embeds: [new EmojiEmbed()
-        .setTitle("Attachment Log Channel")
-        .setDescription(channel ? `Your attachment log channel is currently set to <#${channel}>` : "This server does not have an attachment log channel")
-        .setStatus("Success")
-        .setEmoji("CHANNEL.TEXT.CREATE")
-        .setFooter({text: "Message closed"})
-    ], components: [new MessageActionRow().addComponents([new MessageButton()
-        .setCustomId("clear")
-        .setLabel("Clear")
-        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-        .setStyle("SECONDARY")
-        .setDisabled(true)
-    ])]});
+    await interaction.editReply({
+        embeds: [
+            new EmojiEmbed()
+                .setTitle("Attachment Log Channel")
+                .setDescription(
+                    channel
+                        ? `Your attachment log channel is currently set to <#${channel}>`
+                        : "This server does not have an attachment log channel"
+                )
+                .setStatus("Success")
+                .setEmoji("CHANNEL.TEXT.CREATE")
+                .setFooter({ text: "Message closed" })
+        ],
+        components: [
+            new MessageActionRow().addComponents([
+                new MessageButton()
+                    .setCustomId("clear")
+                    .setLabel("Clear")
+                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                    .setStyle("SECONDARY")
+                    .setDisabled(true)
+            ])
+        ]
+    });
 };
 
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 4d4a392..00d2411 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,6 +1,10 @@
 import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
 import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    MessageActionRow,
+    MessageButton
+} from "discord.js";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../../utils/confirmationMessage.js";
 import getEmojiByName from "../../../utils/getEmojiByName.js";
@@ -12,47 +16,71 @@
     builder
         .setName("channel")
         .setDescription("Sets or shows the log channel")
-        .addChannelOption(option => option.setName("channel").setDescription("The channel to set the log channel to").addChannelTypes([
-            ChannelType.GuildNews, ChannelType.GuildText
-        ]));
+        .addChannelOption((option) =>
+            option
+                .setName("channel")
+                .setDescription("The channel to set the log channel to")
+                .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message;
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    const m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    })) as Discord.Message;
     if (interaction.options.getChannel("channel")) {
         let channel;
         try {
             channel = interaction.options.getChannel("channel");
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("CHANNEL.TEXT.DELETE")
-                .setTitle("Log Channel")
-                .setDescription("The channel you provided is not a valid channel")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                        .setTitle("Log Channel")
+                        .setDescription(
+                            "The channel you provided is not a valid channel"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Log Channel")
-                .setDescription("You must choose a channel in this server")
-                .setStatus("Danger")
-                .setEmoji("CHANNEL.TEXT.DELETE")
-            ]});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Log Channel")
+                        .setDescription(
+                            "You must choose a channel in this server"
+                        )
+                        .setStatus("Danger")
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                ]
+            });
         }
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Log Channel")
-            .setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`)
+            .setDescription(
+                `Are you sure you want to set the log channel to <#${channel.id}>?`
+            )
             .setColor("Warning")
             .setInverted(true)
             .send(true);
         if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id});
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                await client.database.guilds.write(interaction.guild.id, {
+                    "logging.logs.channel": channel.id
+                });
+                const { log, NucleusColors, entry, renderUser, renderChannel } =
+                    client.logger;
                 const data = {
-                    meta:{
+                    meta: {
                         type: "logChannelUpdate",
                         displayName: "Log Channel Changed",
                         calculateType: "nucleusSettingsUpdated",
@@ -61,8 +89,14 @@
                         timestamp: new Date().getTime()
                     },
                     list: {
-                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        memberId: entry(
+                            interaction.user.id,
+                            `\`${interaction.user.id}\``
+                        ),
+                        changedBy: entry(
+                            interaction.user.id,
+                            renderUser(interaction.user)
+                        ),
                         channel: entry(channel.id, renderChannel(channel))
                     },
                     hidden: {
@@ -72,72 +106,119 @@
                 log(data);
             } catch (e) {
                 console.log(e);
-                return interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Log Channel")
-                    .setDescription("Something went wrong and the log channel could not be set")
-                    .setStatus("Danger")
-                    .setEmoji("CHANNEL.TEXT.DELETE")
-                ], components: []});
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Log Channel")
+                            .setDescription(
+                                "Something went wrong and the log channel could not be set"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                    ],
+                    components: []
+                });
             }
         } else {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Log Channel")
-                .setDescription("No changes were made")
-                .setStatus("Success")
-                .setEmoji("CHANNEL.TEXT.CREATE")
-            ], components: []});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Log Channel")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("CHANNEL.TEXT.CREATE")
+                ],
+                components: []
+            });
         }
     }
     let clicks = 0;
     const data = await client.database.guilds.read(interaction.guild.id);
     let channel = data.logging.logs.channel;
     while (true) {
-        await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Log channel")
-            .setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
-            .setStatus("Success")
-            .setEmoji("CHANNEL.TEXT.CREATE")
-        ], components: [new MessageActionRow().addComponents([new MessageButton()
-            .setCustomId("clear")
-            .setLabel(clicks ? "Click again to confirm" : "Reset channel")
-            .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
-            .setStyle("DANGER")
-            .setDisabled(!channel)
-        ])]});
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Log channel")
+                    .setDescription(
+                        channel
+                            ? `Your log channel is currently set to <#${channel}>`
+                            : "This server does not have a log channel"
+                    )
+                    .setStatus("Success")
+                    .setEmoji("CHANNEL.TEXT.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setCustomId("clear")
+                        .setLabel(
+                            clicks ? "Click again to confirm" : "Reset channel"
+                        )
+                        .setEmoji(
+                            getEmojiByName(
+                                clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+                                "id"
+                            )
+                        )
+                        .setStyle("DANGER")
+                        .setDisabled(!channel)
+                ])
+            ]
+        });
         let i;
         try {
-            i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break; }
+            i = await m.awaitMessageComponent({ time: 300000 });
+        } catch (e) {
+            break;
+        }
         i.deferUpdate();
         if (i.component.customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "logging.logs.channel"
+                ]);
                 channel = undefined;
             }
         } else {
             break;
         }
     }
-    await interaction.editReply({embeds: [new EmojiEmbed()
-        .setTitle("Log channel")
-        .setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
-        .setStatus("Success")
-        .setEmoji("CHANNEL.TEXT.CREATE")
-        .setFooter({text: "Message closed"})
-    ], components: [new MessageActionRow().addComponents([new MessageButton()
-        .setCustomId("clear")
-        .setLabel("Clear")
-        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-        .setStyle("SECONDARY")
-        .setDisabled(true)
-    ])]});
+    await interaction.editReply({
+        embeds: [
+            new EmojiEmbed()
+                .setTitle("Log channel")
+                .setDescription(
+                    channel
+                        ? `Your log channel is currently set to <#${channel}>`
+                        : "This server does not have a log channel"
+                )
+                .setStatus("Success")
+                .setEmoji("CHANNEL.TEXT.CREATE")
+                .setFooter({ text: "Message closed" })
+        ],
+        components: [
+            new MessageActionRow().addComponents([
+                new MessageButton()
+                    .setCustomId("clear")
+                    .setLabel("Clear")
+                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                    .setStyle("SECONDARY")
+                    .setDisabled(true)
+            ])
+        ]
+    });
 };
 
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 110c70e..a1edcaf 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,33 +1,37 @@
 import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    MessageActionRow,
+    MessageButton,
+    MessageSelectMenu
+} from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
 import client from "../../../utils/client.js";
 import { toHexArray, toHexInteger } from "../../../utils/calculate.js";
 
-
 const logs = {
-    "channelUpdate": "Channels created, deleted or modified",
-    "emojiUpdate": "Server emojis modified",
-    "stickerUpdate": "Server stickers modified",
-    "guildUpdate": "Server settings updated",
-    "guildMemberUpdate": "Member updated (i.e. nickname)",
-    "guildMemberPunish": "Members punished (i.e. muted, banned, kicked)",
-    "guildRoleUpdate": "Role settings changed",
-    "guildInviteUpdate": "Server invite created or deleted",
-    "messageUpdate": "Message edited",
-    "messageDelete": "Message deleted",
-    "messageDeleteBulk": "Messages purged",
-    "messageReactionUpdate": "Message reactions cleared",
-    "messageMassPing": "Message pings multiple members at once",
-    "messageAnnounce": "Message published in announcement channel",
-    "threadUpdate": "Thread created or deleted",
-    "webhookUpdate": "Webhooks created or deleted",
-    "guildMemberVerify": "Member runs verify",
-    "autoModeratorDeleted": "Messages auto deleted by Nucleus",
-    "nucleusSettingsUpdated": "Nucleus' settings updated by a moderator",
-    "ticketUpdate": "Tickets created or deleted"
+    channelUpdate: "Channels created, deleted or modified",
+    emojiUpdate: "Server emojis modified",
+    stickerUpdate: "Server stickers modified",
+    guildUpdate: "Server settings updated",
+    guildMemberUpdate: "Member updated (i.e. nickname)",
+    guildMemberPunish: "Members punished (i.e. muted, banned, kicked)",
+    guildRoleUpdate: "Role settings changed",
+    guildInviteUpdate: "Server invite created or deleted",
+    messageUpdate: "Message edited",
+    messageDelete: "Message deleted",
+    messageDeleteBulk: "Messages purged",
+    messageReactionUpdate: "Message reactions cleared",
+    messageMassPing: "Message pings multiple members at once",
+    messageAnnounce: "Message published in announcement channel",
+    threadUpdate: "Thread created or deleted",
+    webhookUpdate: "Webhooks created or deleted",
+    guildMemberVerify: "Member runs verify",
+    autoModeratorDeleted: "Messages auto deleted by Nucleus",
+    nucleusSettingsUpdated: "Nucleus' settings updated by a moderator",
+    ticketUpdate: "Tickets created or deleted"
 };
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -36,39 +40,52 @@
         .setDescription("Sets what events should be logged");
 
 const callback = async (interaction: CommandInteraction): Promise<void> => {
-    await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+    await interaction.reply({
+        embeds: LoadingEmbed,
+        fetchReply: true,
+        ephemeral: true
+    });
     let m;
     while (true) {
         const config = await client.database.guilds.read(interaction.guild.id);
         const converted = toHexArray(config.logging.logs.toLog);
-        m = await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Logging Events")
-            .setDescription("Below are the events being logged in the server. You can toggle them on and off in the dropdown")
-            .setStatus("Success")
-            .setEmoji("CHANNEL.TEXT.CREATE")
-        ], components: [
-            new MessageActionRow().addComponents([new MessageSelectMenu()
-                .setPlaceholder("Set events to log")
-                .setMaxValues(Object.keys(logs).length)
-                .setCustomId("logs")
-                .setMinValues(0)
-                .setOptions(Object.keys(logs).map((e, i) => ({
-                    label: logs[e],
-                    value: i.toString(),
-                    default: converted.includes(e)
-                })))
-            ]),
-            new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setLabel("Select all")
-                    .setStyle("PRIMARY")
-                    .setCustomId("all"),
-                new MessageButton()
-                    .setLabel("Select none")
-                    .setStyle("DANGER")
-                    .setCustomId("none")
-            ])
-        ]});
+        m = await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Logging Events")
+                    .setDescription(
+                        "Below are the events being logged in the server. You can toggle them on and off in the dropdown"
+                    )
+                    .setStatus("Success")
+                    .setEmoji("CHANNEL.TEXT.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageSelectMenu()
+                        .setPlaceholder("Set events to log")
+                        .setMaxValues(Object.keys(logs).length)
+                        .setCustomId("logs")
+                        .setMinValues(0)
+                        .setOptions(
+                            Object.keys(logs).map((e, i) => ({
+                                label: logs[e],
+                                value: i.toString(),
+                                default: converted.includes(e)
+                            }))
+                        )
+                ]),
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel("Select all")
+                        .setStyle("PRIMARY")
+                        .setCustomId("all"),
+                    new MessageButton()
+                        .setLabel("Select none")
+                        .setStyle("DANGER")
+                        .setCustomId("none")
+                ])
+            ]
+        });
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
@@ -78,33 +95,50 @@
         i.deferUpdate();
         if (i.customId === "logs") {
             const selected = i.values;
-            const newLogs = toHexInteger(selected.map(e => Object.keys(logs)[parseInt(e)]));
-            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
+            const newLogs = toHexInteger(
+                selected.map((e) => Object.keys(logs)[parseInt(e)])
+            );
+            await client.database.guilds.write(interaction.guild.id, {
+                "logging.logs.toLog": newLogs
+            });
         } else if (i.customId === "all") {
-            const newLogs = toHexInteger(Object.keys(logs).map(e => e));
-            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
+            const newLogs = toHexInteger(Object.keys(logs).map((e) => e));
+            await client.database.guilds.write(interaction.guild.id, {
+                "logging.logs.toLog": newLogs
+            });
         } else if (i.customId === "none") {
-            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": 0});
+            await client.database.guilds.write(interaction.guild.id, {
+                "logging.logs.toLog": 0
+            });
         } else {
             break;
         }
     }
-    m = await interaction.editReply({embeds: [new EmojiEmbed()
-        .setTitle("Logging Events")
-        .setDescription("Below are the events being logged in the server. You can toggle them on and off in the dropdown")
-        .setFooter({text: "Message timed out"})
-        .setStatus("Success")
-        .setEmoji("CHANNEL.TEXT.CREATE")
-    ]});
+    m = await interaction.editReply({
+        embeds: [
+            new EmojiEmbed()
+                .setTitle("Logging Events")
+                .setDescription(
+                    "Below are the events being logged in the server. You can toggle them on and off in the dropdown"
+                )
+                .setFooter({ text: "Message timed out" })
+                .setStatus("Success")
+                .setEmoji("CHANNEL.TEXT.CREATE")
+        ]
+    });
     return;
 };
 
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 2f0c819..718d13b 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,12 +1,16 @@
 import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
 import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    MessageActionRow,
+    MessageButton
+} from "discord.js";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../../utils/confirmationMessage.js";
 import getEmojiByName from "../../../utils/getEmojiByName.js";
 import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
 import type { WrappedCheck } from "jshaiku";
 import client from "../../../utils/client.js";
 
@@ -14,40 +18,62 @@
     builder
         .setName("staff")
         .setDescription("Settings for the staff notifications channel")
-        .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
-            ChannelType.GuildNews, ChannelType.GuildText
-        ]).setRequired(false));
+        .addChannelOption((option) =>
+            option
+                .setName("channel")
+                .setDescription(
+                    "The channel to set the staff notifications channel to"
+                )
+                .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+                .setRequired(false)
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<unknown | void> => {
+const callback = async (
+    interaction: CommandInteraction
+): Promise<unknown | void> => {
     if (!interaction.guild) return;
-    const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message<boolean>;
+    const m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    })) as Discord.Message;
     if (interaction.options.getChannel("channel")) {
         let channel;
         try {
             channel = interaction.options.getChannel("channel");
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("CHANNEL.TEXT.DELETE")
-                .setTitle("Staff Notifications Channel")
-                .setDescription("The channel you provided is not a valid channel")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                        .setTitle("Staff Notifications Channel")
+                        .setDescription(
+                            "The channel you provided is not a valid channel"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Staff Notifications Channel")
-                .setDescription("You must choose a channel in this server")
-                .setStatus("Danger")
-                .setEmoji("CHANNEL.TEXT.DELETE")
-            ]});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Staff Notifications Channel")
+                        .setDescription(
+                            "You must choose a channel in this server"
+                        )
+                        .setStatus("Danger")
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                ]
+            });
         }
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Staff Notifications Channel")
             .setDescription(
                 "This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n" +
-                `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
+                    `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
             )
             .setColor("Warning")
             .setInverted(true)
@@ -55,10 +81,13 @@
         if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id});
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                await client.database.guilds.write(interaction.guild.id, {
+                    "logging.staff.channel": channel.id
+                });
+                const { log, NucleusColors, entry, renderUser, renderChannel } =
+                    client.logger;
                 const data = {
-                    meta:{
+                    meta: {
                         type: "staffChannelUpdate",
                         displayName: "Staff Notifications Channel Updated",
                         calculateType: "nucleusSettingsUpdated",
@@ -67,8 +96,14 @@
                         timestamp: new Date().getTime()
                     },
                     list: {
-                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        memberId: entry(
+                            interaction.user.id,
+                            `\`${interaction.user.id}\``
+                        ),
+                        changedBy: entry(
+                            interaction.user.id,
+                            renderUser(interaction.user)
+                        ),
                         channel: entry(channel.id, renderChannel(channel))
                     },
                     hidden: {
@@ -77,72 +112,119 @@
                 };
                 log(data);
             } catch (e) {
-                return interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Staff Notifications Channel")
-                    .setDescription("Something went wrong and the staff notifications channel could not be set")
-                    .setStatus("Danger")
-                    .setEmoji("CHANNEL.TEXT.DELETE")
-                ], components: []});
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Staff Notifications Channel")
+                            .setDescription(
+                                "Something went wrong and the staff notifications channel could not be set"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                    ],
+                    components: []
+                });
             }
         } else {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Staff Notifications Channel")
-                .setDescription("No changes were made")
-                .setStatus("Success")
-                .setEmoji("CHANNEL.TEXT.CREATE")
-            ], components: []});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Staff Notifications Channel")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("CHANNEL.TEXT.CREATE")
+                ],
+                components: []
+            });
         }
     }
     let clicks = 0;
     const data = await client.database.guilds.read(interaction.guild.id);
     let channel = data.logging.staff.channel;
     while (true) {
-        await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Staff Notifications channel")
-            .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
-            .setStatus("Success")
-            .setEmoji("CHANNEL.TEXT.CREATE")
-        ], components: [new MessageActionRow().addComponents([new MessageButton()
-            .setCustomId("clear")
-            .setLabel(clicks ? "Click again to confirm" : "Reset channel")
-            .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
-            .setStyle("DANGER")
-            .setDisabled(!channel)
-        ])]});
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Staff Notifications channel")
+                    .setDescription(
+                        channel
+                            ? `Your staff notifications channel is currently set to <#${channel}>`
+                            : "This server does not have a staff notifications channel"
+                    )
+                    .setStatus("Success")
+                    .setEmoji("CHANNEL.TEXT.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setCustomId("clear")
+                        .setLabel(
+                            clicks ? "Click again to confirm" : "Reset channel"
+                        )
+                        .setEmoji(
+                            getEmojiByName(
+                                clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+                                "id"
+                            )
+                        )
+                        .setStyle("DANGER")
+                        .setDisabled(!channel)
+                ])
+            ]
+        });
         let i;
         try {
-            i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break; }
+            i = await m.awaitMessageComponent({ time: 300000 });
+        } catch (e) {
+            break;
+        }
         i.deferUpdate();
         if ((i.component as MessageButton).customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "logging.staff.channel"
+                ]);
                 channel = undefined;
             }
         } else {
             break;
         }
     }
-    await interaction.editReply({embeds: [new EmojiEmbed()
-        .setTitle("Staff Notifications channel")
-        .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
-        .setStatus("Success")
-        .setEmoji("CHANNEL.TEXT.CREATE")
-        .setFooter({text: "Message closed"})
-    ], components: [new MessageActionRow().addComponents([new MessageButton()
-        .setCustomId("clear")
-        .setLabel("Clear")
-        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-        .setStyle("SECONDARY")
-        .setDisabled(true)
-    ])]});
+    await interaction.editReply({
+        embeds: [
+            new EmojiEmbed()
+                .setTitle("Staff Notifications channel")
+                .setDescription(
+                    channel
+                        ? `Your staff notifications channel is currently set to <#${channel}>`
+                        : "This server does not have a staff notifications channel"
+                )
+                .setStatus("Success")
+                .setEmoji("CHANNEL.TEXT.CREATE")
+                .setFooter({ text: "Message closed" })
+        ],
+        components: [
+            new MessageActionRow().addComponents([
+                new MessageButton()
+                    .setCustomId("clear")
+                    .setLabel("Clear")
+                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                    .setStyle("SECONDARY")
+                    .setDisabled(true)
+            ])
+        ]
+    });
 };
 
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 9a4ceb0..beb2f35 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -5,20 +5,28 @@
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
         .setName("rolemenu")
-        .setDescription("rolemenu")// TODO
-        .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying")); // FIXME FOR FUCK SAKE
+        .setDescription("rolemenu") // TODO
+        .addRoleOption((option) =>
+            option
+                .setName("role")
+                .setDescription("The role to give after verifying")
+        ); // FIXME FOR FUCK SAKE
 
 const callback = async (interaction: CommandInteraction): Promise<void> => {
     console.log("we changed the charger again because fuck you");
     await interaction.reply("You're mum");
 };
 
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the *Manage Roles* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_ROLES"))
+        throw "You must have the *Manage Roles* permission to use this command";
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 5a1affd..507e506 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,62 +1,112 @@
 import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, Message, MessageActionRow, MessageSelectMenu } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    Message,
+    MessageActionRow,
+    MessageSelectMenu
+} from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import client from "../../utils/client.js";
 import convertCurlyBracketString from "../../utils/convertCurlyBracketString.js";
-import {callback as statsChannelAddCallback} from "../../reflex/statsChannelUpdate.js";
+import { callback as statsChannelAddCallback } from "../../reflex/statsChannelUpdate.js";
 import singleNotify from "../../utils/singleNotify.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
         .setName("stats")
-        .setDescription("Controls channels which update when someone joins or leaves the server")
-        .addChannelOption(option => option.setName("channel").setDescription("The channel to modify"))
-        .addStringOption(option => option.setName("name").setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}").setAutocomplete(true));
+        .setDescription(
+            "Controls channels which update when someone joins or leaves the server"
+        )
+        .addChannelOption((option) =>
+            option.setName("channel").setDescription("The channel to modify")
+        )
+        .addStringOption((option) =>
+            option
+                .setName("name")
+                .setDescription(
+                    "The new channel name | Enter any text or use the extra variables like {memberCount}"
+                )
+                .setAutocomplete(true)
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
     singleNotify("statsChannelDeleted", interaction.guild.id, true);
-    const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Message;
+    const m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    })) as Message;
     let config = await client.database.guilds.read(interaction.guild.id);
     if (interaction.options.getString("name")) {
         let channel;
         if (Object.keys(config.getKey("stats")).length >= 25) {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("CHANNEL.TEXT.DELETE")
-                .setTitle("Stats Channel")
-                .setDescription("You can only have 25 stats channels in a server")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                        .setTitle("Stats Channel")
+                        .setDescription(
+                            "You can only have 25 stats channels in a server"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         try {
             channel = interaction.options.getChannel("channel");
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("CHANNEL.TEXT.DELETE")
-                .setTitle("Stats Channel")
-                .setDescription("The channel you provided is not a valid channel")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                        .setTitle("Stats Channel")
+                        .setDescription(
+                            "The channel you provided is not a valid channel"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Stats Channel")
-                .setDescription("You must choose a channel in this server")
-                .setStatus("Danger")
-                .setEmoji("CHANNEL.TEXT.DELETE")
-            ]});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Stats Channel")
+                        .setDescription(
+                            "You must choose a channel in this server"
+                        )
+                        .setStatus("Danger")
+                        .setEmoji("CHANNEL.TEXT.DELETE")
+                ]
+            });
         }
-        let newName = await convertCurlyBracketString(interaction.options.getString("name"), null, null, interaction.guild.name, interaction.guild.members);
+        let newName = await convertCurlyBracketString(
+            interaction.options.getString("name"),
+            null,
+            null,
+            interaction.guild.name,
+            interaction.guild.members
+        );
         if (interaction.options.getChannel("channel").type === "GUILD_TEXT") {
             newName = newName.toLowerCase().replace(/[\s]/g, "-");
         }
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Stats Channel")
-            .setDescription(`Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(/^ +| $/g, "")}*`)
+            .setDescription(
+                `Are you sure you want to set <#${
+                    channel.id
+                }> to a stats channel?\n\n*Preview: ${newName.replace(
+                    /^ +| $/g,
+                    ""
+                )}*`
+            )
             .setColor("Warning")
             .setInverted(true)
             .send(true);
@@ -65,10 +115,13 @@
             try {
                 const name = interaction.options.getString("name");
                 const channel = interaction.options.getChannel("channel");
-                await client.database.guilds.write(interaction.guild.id, {[`stats.${channel.id}`]: {name: name, enabled: true}});
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                await client.database.guilds.write(interaction.guild.id, {
+                    [`stats.${channel.id}`]: { name: name, enabled: true }
+                });
+                const { log, NucleusColors, entry, renderUser, renderChannel } =
+                    client.logger;
                 const data = {
-                    meta:{
+                    meta: {
                         type: "statsChannelUpdate",
                         displayName: "Stats Channel Updated",
                         calculateType: "nucleusSettingsUpdated",
@@ -77,10 +130,19 @@
                         timestamp: new Date().getTime()
                     },
                     list: {
-                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        memberId: entry(
+                            interaction.user.id,
+                            `\`${interaction.user.id}\``
+                        ),
+                        changedBy: entry(
+                            interaction.user.id,
+                            renderUser(interaction.user)
+                        ),
                         channel: entry(channel.id, renderChannel(channel)),
-                        name: entry(interaction.options.getString("name"), `\`${interaction.options.getString("name")}\``)
+                        name: entry(
+                            interaction.options.getString("name"),
+                            `\`${interaction.options.getString("name")}\``
+                        )
                     },
                     hidden: {
                         guild: interaction.guild.id
@@ -89,20 +151,30 @@
                 log(data);
             } catch (e) {
                 console.log(e);
-                return interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Stats Channel")
-                    .setDescription("Something went wrong and the stats channel could not be set")
-                    .setStatus("Danger")
-                    .setEmoji("CHANNEL.TEXT.DELETE")
-                ], components: []});
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Stats Channel")
+                            .setDescription(
+                                "Something went wrong and the stats channel could not be set"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                    ],
+                    components: []
+                });
             }
         } else {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Stats Channel")
-                .setDescription("No changes were made")
-                .setStatus("Success")
-                .setEmoji("CHANNEL.TEXT.CREATE")
-            ], components: []});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Stats Channel")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("CHANNEL.TEXT.CREATE")
+                ],
+                components: []
+            });
         }
         await statsChannelAddCallback(client, interaction.member);
     }
@@ -113,41 +185,83 @@
             .setCustomId("remove")
             .setMinValues(1)
             .setMaxValues(Math.max(1, Object.keys(stats).length));
-        await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Stats Channel")
-            .setDescription("The following channels update when someone joins or leaves the server. You can select a channel to remove it from the list.")
-            .setStatus("Success")
-            .setEmoji("CHANNEL.TEXT.CREATE")
-        ], components: [
-            new MessageActionRow().addComponents(Object.keys(stats).length ? [
-                selectMenu.setPlaceholder("Select a stats channel to remove, stopping it updating").addOptions(Object.keys(stats).map(key => ({
-                    label: interaction.guild.channels.cache.get(key).name,
-                    value: key,
-                    description: `${stats[key].name}`
-                })))
-            ] : [selectMenu.setPlaceholder("The server has no stats channels").setDisabled(true).setOptions([
-                {label: "*Placeholder*", value: "placeholder", description: "No stats channels"}
-            ])])
-        ]});
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Stats Channel")
+                    .setDescription(
+                        "The following channels update when someone joins or leaves the server. You can select a channel to remove it from the list."
+                    )
+                    .setStatus("Success")
+                    .setEmoji("CHANNEL.TEXT.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents(
+                    Object.keys(stats).length
+                        ? [
+                              selectMenu
+                                  .setPlaceholder(
+                                      "Select a stats channel to remove, stopping it updating"
+                                  )
+                                  .addOptions(
+                                      Object.keys(stats).map((key) => ({
+                                          label: interaction.guild.channels.cache.get(
+                                              key
+                                          ).name,
+                                          value: key,
+                                          description: `${stats[key].name}`
+                                      }))
+                                  )
+                          ]
+                        : [
+                              selectMenu
+                                  .setPlaceholder(
+                                      "The server has no stats channels"
+                                  )
+                                  .setDisabled(true)
+                                  .setOptions([
+                                      {
+                                          label: "*Placeholder*",
+                                          value: "placeholder",
+                                          description: "No stats channels"
+                                      }
+                                  ])
+                          ]
+                )
+            ]
+        });
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { break; }
+        } catch (e) {
+            break;
+        }
         i.deferUpdate();
         if (i.customId === "remove") {
             const toRemove = i.values;
-            await client.database.guilds.write(interaction.guild.id, null, toRemove.map(k => `stats.${k}`));
+            await client.database.guilds.write(
+                interaction.guild.id,
+                null,
+                toRemove.map((k) => `stats.${k}`)
+            );
         }
     }
-    await interaction.editReply({embeds: [(m.embeds[0] as Discord.MessageEmbed).setFooter({text: "Message closed"})], components: []});
+    await interaction.editReply({
+        embeds: [m.embeds[0]!.setFooter({ text: "Message closed" })],
+        components: []
+    });
 };
 
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_CHANNELS")) throw "You must have the *Manage Channels* permission to use this command";
+const check = (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_CHANNELS"))
+        throw "You must have the *Manage Channels* permission to use this command";
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index f9df71c..5e5cbe7 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -2,103 +2,198 @@
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
-import Discord, { CommandInteraction, GuildChannel, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, MessageSelectMenu, Role, SelectMenuInteraction, TextInputComponent } from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import Discord, {
+    CommandInteraction,
+    GuildChannel,
+    Message,
+    MessageActionRow,
+    MessageActionRowComponent,
+    MessageButton,
+    MessageComponentInteraction,
+    MessageSelectMenu,
+    Role,
+    SelectMenuInteraction,
+    TextInputComponent
+} from "discord.js";
+import {
+    SelectMenuOption,
+    SlashCommandSubcommandBuilder
+} from "@discordjs/builders";
 import { ChannelType } from "discord-api-types";
 import client from "../../utils/client.js";
-import { toHexInteger, toHexArray, tickets as ticketTypes } from "../../utils/calculate.js";
+import {
+    toHexInteger,
+    toHexArray,
+    tickets as ticketTypes
+} from "../../utils/calculate.js";
 import { capitalize } from "../../utils/generateKeyValueList.js";
 import { modalInteractionCollector } from "../../utils/dualCollector.js";
-import {GuildConfig} from "../../utils/database.js";
+import { GuildConfig } from "../../utils/database.js";
 
-const command = (builder: SlashCommandSubcommandBuilder) => builder
-    .setName("tickets")
-    .setDescription("Shows settings for tickets | Use no arguments to manage custom types")
-    .addStringOption(option => option.setName("enabled").setDescription("If users should be able to create tickets").setRequired(false)
-        .addChoices([["Yes", "yes"], ["No", "no"]]))
-    .addChannelOption(option => option.setName("category").setDescription("The category where tickets are created").addChannelType(ChannelType.GuildCategory).setRequired(false))
-    .addNumberOption(option => option.setName("maxticketsperuser").setDescription("The maximum amount of tickets a user can create | Default: 5").setRequired(false).setMinValue(1))
-    .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false));
+const command = (builder: SlashCommandSubcommandBuilder) =>
+    builder
+        .setName("tickets")
+        .setDescription(
+            "Shows settings for tickets | Use no arguments to manage custom types"
+        )
+        .addStringOption((option) =>
+            option
+                .setName("enabled")
+                .setDescription("If users should be able to create tickets")
+                .setRequired(false)
+                .addChoices([
+                    ["Yes", "yes"],
+                    ["No", "no"]
+                ])
+        )
+        .addChannelOption((option) =>
+            option
+                .setName("category")
+                .setDescription("The category where tickets are created")
+                .addChannelType(ChannelType.GuildCategory)
+                .setRequired(false)
+        )
+        .addNumberOption((option) =>
+            option
+                .setName("maxticketsperuser")
+                .setDescription(
+                    "The maximum amount of tickets a user can create | Default: 5"
+                )
+                .setRequired(false)
+                .setMinValue(1)
+        )
+        .addRoleOption((option) =>
+            option
+                .setName("supportrole")
+                .setDescription(
+                    "This role will have view access to all tickets and will be pinged when a ticket is created"
+                )
+                .setRequired(false)
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    let m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Message;
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    let m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    })) as Message;
     const options = {
         enabled: interaction.options.getString("enabled") as string | boolean,
         category: interaction.options.getChannel("category"),
         maxtickets: interaction.options.getNumber("maxticketsperuser"),
         supportping: interaction.options.getRole("supportrole")
     };
-    if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
+    if (
+        options.enabled !== null ||
+        options.category ||
+        options.maxtickets ||
+        options.supportping
+    ) {
         options.enabled = options.enabled === "yes" ? true : false;
         if (options.category) {
             let channel: GuildChannel;
             try {
-                channel = await interaction.guild.channels.fetch(options.category.id);
+                channel = await interaction.guild.channels.fetch(
+                    options.category.id
+                );
             } catch {
                 return await interaction.editReply({
-                    embeds: [new EmojiEmbed()
-                        .setEmoji("CHANNEL.TEXT.DELETE")
-                        .setTitle("Tickets > Category")
-                        .setDescription("The channel you provided is not a valid category")
-                        .setStatus("Danger")
+                    embeds: [
+                        new EmojiEmbed()
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                            .setTitle("Tickets > Category")
+                            .setDescription(
+                                "The channel you provided is not a valid category"
+                            )
+                            .setStatus("Danger")
                     ]
                 });
             }
             channel = channel as Discord.CategoryChannel;
-            if (channel.guild.id !== interaction.guild.id) return interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets > Category")
-                    .setDescription("You must choose a category in this server")
-                    .setStatus("Danger")
-                    .setEmoji("CHANNEL.TEXT.DELETE")
-                ]
-            });
+            if (channel.guild.id !== interaction.guild.id)
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Tickets > Category")
+                            .setDescription(
+                                "You must choose a category in this server"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                    ]
+                });
         }
         if (options.maxtickets) {
-            if (options.maxtickets < 1) return interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets > Max Tickets")
-                    .setDescription("You must choose a number greater than 0")
-                    .setStatus("Danger")
-                    .setEmoji("CHANNEL.TEXT.DELETE")
-                ]
-            });
+            if (options.maxtickets < 1)
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Tickets > Max Tickets")
+                            .setDescription(
+                                "You must choose a number greater than 0"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("CHANNEL.TEXT.DELETE")
+                    ]
+                });
         }
         let role: Role;
         if (options.supportping) {
             try {
-                role = await interaction.guild.roles.fetch(options.supportping.id);
+                role = await interaction.guild.roles.fetch(
+                    options.supportping.id
+                );
             } catch {
                 return await interaction.editReply({
-                    embeds: [new EmojiEmbed()
-                        .setEmoji("GUILD.ROLE.DELETE")
-                        .setTitle("Tickets > Support Ping")
-                        .setDescription("The role you provided is not a valid role")
-                        .setStatus("Danger")
+                    embeds: [
+                        new EmojiEmbed()
+                            .setEmoji("GUILD.ROLE.DELETE")
+                            .setTitle("Tickets > Support Ping")
+                            .setDescription(
+                                "The role you provided is not a valid role"
+                            )
+                            .setStatus("Danger")
                     ]
                 });
             }
             role = role as Discord.Role;
-            if (role.guild.id !== interaction.guild.id) return interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets > Support Ping")
-                    .setDescription("You must choose a role in this server")
-                    .setStatus("Danger")
-                    .setEmoji("GUILD.ROLE.DELETE")
-                ]
-            });
+            if (role.guild.id !== interaction.guild.id)
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Tickets > Support Ping")
+                            .setDescription(
+                                "You must choose a role in this server"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("GUILD.ROLE.DELETE")
+                    ]
+                });
         }
 
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.TICKET.ARCHIVED")
             .setTitle("Tickets")
             .setDescription(
-                (options.category ? `**Category:** ${options.category.name}\n` : "") +
-                (options.maxtickets ? `**Max Tickets:** ${options.maxtickets}\n` : "") +
-                (options.supportping ? `**Support Ping:** ${options.supportping.name}\n` : "") +
-                (options.enabled !== null ? `**Enabled:** ${options.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-                }\n` : "") +
-                "\nAre you sure you want to apply these settings?"
+                (options.category
+                    ? `**Category:** ${options.category.name}\n`
+                    : "") +
+                    (options.maxtickets
+                        ? `**Max Tickets:** ${options.maxtickets}\n`
+                        : "") +
+                    (options.supportping
+                        ? `**Support Ping:** ${options.supportping.name}\n`
+                        : "") +
+                    (options.enabled !== null
+                        ? `**Enabled:** ${
+                              options.enabled
+                                  ? `${getEmojiByName("CONTROL.TICK")} Yes`
+                                  : `${getEmojiByName("CONTROL.CROSS")} No`
+                          }\n`
+                        : "") +
+                    "\nAre you sure you want to apply these settings?"
             )
             .setColor("Warning")
             .setInverted(true)
@@ -106,35 +201,51 @@
         if (confirmation.cancelled) return;
         if (confirmation.success) {
             const toUpdate = {};
-            if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled;
-            if (options.category) toUpdate["tickets.category"] = options.category.id;
-            if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets;
-            if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id;
+            if (options.enabled !== null)
+                toUpdate["tickets.enabled"] = options.enabled;
+            if (options.category)
+                toUpdate["tickets.category"] = options.category.id;
+            if (options.maxtickets)
+                toUpdate["tickets.maxTickets"] = options.maxtickets;
+            if (options.supportping)
+                toUpdate["tickets.supportRole"] = options.supportping.id;
             try {
-                await client.database.guilds.write(interaction.guild.id, toUpdate);
+                await client.database.guilds.write(
+                    interaction.guild.id,
+                    toUpdate
+                );
             } catch (e) {
                 return interaction.editReply({
-                    embeds: [new EmojiEmbed()
-                        .setTitle("Tickets")
-                        .setDescription("Something went wrong and the staff notifications channel could not be set")
-                        .setStatus("Danger")
-                        .setEmoji("GUILD.TICKET.DELETE")
-                    ], components: []
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Tickets")
+                            .setDescription(
+                                "Something went wrong and the staff notifications channel could not be set"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("GUILD.TICKET.DELETE")
+                    ],
+                    components: []
                 });
             }
         } else {
             return interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets")
-                    .setDescription("No changes were made")
-                    .setStatus("Success")
-                    .setEmoji("GUILD.TICKET.OPEN")
-                ], components: []
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Tickets")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("GUILD.TICKET.OPEN")
+                ],
+                components: []
             });
         }
     }
     let data = await client.database.guilds.read(interaction.guild.id);
-    data.tickets.customTypes = (data.tickets.customTypes || []).filter((value: string, index: number, array: string[]) => array.indexOf(value) === index);
+    data.tickets.customTypes = (data.tickets.customTypes || []).filter(
+        (value: string, index: number, array: string[]) =>
+            array.indexOf(value) === index
+    );
     let lastClicked = "";
     let embed: EmojiEmbed;
     data = {
@@ -150,235 +261,449 @@
         embed = new EmojiEmbed()
             .setTitle("Tickets")
             .setDescription(
-                `${data.enabled ? "" : getEmojiByName("TICKETS.REPORT")} **Enabled:** ${data.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`}\n` +
-                `${data.category ? "" : getEmojiByName("TICKETS.REPORT")} **Category:** ${data.category ? `<#${data.category}>` : "*None set*"}\n` +
-                `**Max Tickets:** ${data.maxTickets ? data.maxTickets : "*No limit*"}\n` +
-                `**Support Ping:** ${data.supportRole ? `<@&${data.supportRole}>` : "*None set*"}\n\n` +
-                ((data.useCustom && data.customTypes === null) ? `${getEmojiByName("TICKETS.REPORT")} ` : "") +
-                `${data.useCustom ? "Custom" : "Default"} types in use` + "\n\n" +
-                `${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
+                `${
+                    data.enabled ? "" : getEmojiByName("TICKETS.REPORT")
+                } **Enabled:** ${
+                    data.enabled
+                        ? `${getEmojiByName("CONTROL.TICK")} Yes`
+                        : `${getEmojiByName("CONTROL.CROSS")} No`
+                }\n` +
+                    `${
+                        data.category ? "" : getEmojiByName("TICKETS.REPORT")
+                    } **Category:** ${
+                        data.category ? `<#${data.category}>` : "*None set*"
+                    }\n` +
+                    `**Max Tickets:** ${
+                        data.maxTickets ? data.maxTickets : "*No limit*"
+                    }\n` +
+                    `**Support Ping:** ${
+                        data.supportRole
+                            ? `<@&${data.supportRole}>`
+                            : "*None set*"
+                    }\n\n` +
+                    (data.useCustom && data.customTypes === null
+                        ? `${getEmojiByName("TICKETS.REPORT")} `
+                        : "") +
+                    `${data.useCustom ? "Custom" : "Default"} types in use` +
+                    "\n\n" +
+                    `${getEmojiByName(
+                        "TICKETS.REPORT"
+                    )} *Indicates a setting stopping tickets from being used*`
             )
             .setStatus("Success")
             .setEmoji("GUILD.TICKET.OPEN");
-        m = await interaction.editReply({
-            embeds: [embed], components: [new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setLabel("Tickets " + (data.enabled ? "enabled" : "disabled"))
-                    .setEmoji(getEmojiByName("CONTROL." + (data.enabled ? "TICK" : "CROSS"), "id"))
-                    .setStyle(data.enabled ? "SUCCESS" : "DANGER")
-                    .setCustomId("enabled"),
-                new MessageButton()
-                    .setLabel(lastClicked === "cat" ? "Click again to confirm" : "Clear category")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setStyle("DANGER")
-                    .setCustomId("clearCategory")
-                    .setDisabled(data.category === null),
-                new MessageButton()
-                    .setLabel(lastClicked === "max" ? "Click again to confirm" : "Reset max tickets")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setStyle("DANGER")
-                    .setCustomId("clearMaxTickets")
-                    .setDisabled(data.maxTickets === 5),
-                new MessageButton()
-                    .setLabel(lastClicked === "sup" ? "Click again to confirm" : "Clear support ping")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setStyle("DANGER")
-                    .setCustomId("clearSupportPing")
-                    .setDisabled(data.supportRole === null)
-            ]), new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setLabel("Manage types")
-                    .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
-                    .setStyle("SECONDARY")
-                    .setCustomId("manageTypes"),
-                new MessageButton()
-                    .setLabel("Add create ticket button")
-                    .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
-                    .setStyle("PRIMARY")
-                    .setCustomId("send")
-            ])]
-        }) as Message;
+        m = (await interaction.editReply({
+            embeds: [embed],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel(
+                            "Tickets " + (data.enabled ? "enabled" : "disabled")
+                        )
+                        .setEmoji(
+                            getEmojiByName(
+                                "CONTROL." + (data.enabled ? "TICK" : "CROSS"),
+                                "id"
+                            )
+                        )
+                        .setStyle(data.enabled ? "SUCCESS" : "DANGER")
+                        .setCustomId("enabled"),
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked === "cat"
+                                ? "Click again to confirm"
+                                : "Clear category"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setStyle("DANGER")
+                        .setCustomId("clearCategory")
+                        .setDisabled(data.category === null),
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked === "max"
+                                ? "Click again to confirm"
+                                : "Reset max tickets"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setStyle("DANGER")
+                        .setCustomId("clearMaxTickets")
+                        .setDisabled(data.maxTickets === 5),
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked === "sup"
+                                ? "Click again to confirm"
+                                : "Clear support ping"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setStyle("DANGER")
+                        .setCustomId("clearSupportPing")
+                        .setDisabled(data.supportRole === null)
+                ]),
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel("Manage types")
+                        .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
+                        .setStyle("SECONDARY")
+                        .setCustomId("manageTypes"),
+                    new MessageButton()
+                        .setLabel("Add create ticket button")
+                        .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+                        .setStyle("PRIMARY")
+                        .setCustomId("send")
+                ])
+            ]
+        })) as Message;
         let i: MessageComponentInteraction;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { break; }
+        } catch (e) {
+            break;
+        }
         i.deferUpdate();
-        if ((i.component as MessageActionRowComponent).customId === "clearCategory") {
+        if (
+            (i.component as MessageActionRowComponent).customId ===
+            "clearCategory"
+        ) {
             if (lastClicked === "cat") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "tickets.category"
+                ]);
                 data.category = undefined;
             } else lastClicked = "cat";
-        } else if ((i.component as MessageActionRowComponent).customId === "clearMaxTickets") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId ===
+            "clearMaxTickets"
+        ) {
             if (lastClicked === "max") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "tickets.maxTickets"
+                ]);
                 data.maxTickets = 5;
             } else lastClicked = "max";
-        } else if ((i.component as MessageActionRowComponent).customId === "clearSupportPing") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId ===
+            "clearSupportPing"
+        ) {
             if (lastClicked === "sup") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "tickets.supportRole"
+                ]);
                 data.supportRole = undefined;
             } else lastClicked = "sup";
-        } else if ((i.component as MessageActionRowComponent).customId === "send") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "send"
+        ) {
             const ticketMessages = [
-                {label: "Create ticket", description: "Click the button below to create a ticket"},
-                {label: "Issues, questions or feedback?", description: "Click below to open a ticket and get help from our staff team"},
-                {label: "Contact Us", description: "Click the button below to speak to us privately"}
+                {
+                    label: "Create ticket",
+                    description: "Click the button below to create a ticket"
+                },
+                {
+                    label: "Issues, questions or feedback?",
+                    description:
+                        "Click below to open a ticket and get help from our staff team"
+                },
+                {
+                    label: "Contact Us",
+                    description:
+                        "Click the button below to speak to us privately"
+                }
             ];
             while (true) {
                 const enabled = data.enabled && data.category !== null;
-                await interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Ticket Button")
-                    .setDescription("Select a message template to send in this channel")
-                    .setFooter({text: enabled ? "" : "Tickets are not set up correctly so the button may not work for users. Check the main menu to find which options must be set."})
-                    .setStatus(enabled ? "Success" : "Warning")
-                    .setEmoji("GUILD.ROLES.CREATE")
-                ], components: [
-                    new MessageActionRow().addComponents([
-                        new MessageSelectMenu().setOptions(ticketMessages.map((t: {label: string, description: string, value?: string}, index) => {
-                            t.value = index.toString(); return t as {value: string, label: string, description: string};
-                        })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
-                    ]),
-                    new MessageActionRow().addComponents([
-                        new MessageButton()
-                            .setCustomId("back")
-                            .setLabel("Back")
-                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                            .setStyle("DANGER"),
-                        new MessageButton()
-                            .setCustomId("blank")
-                            .setLabel("Empty")
-                            .setStyle("SECONDARY"),
-                        new MessageButton()
-                            .setCustomId("custom")
-                            .setLabel("Custom")
-                            .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
-                            .setStyle("PRIMARY")
-                    ])
-                ]});
+                await interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Ticket Button")
+                            .setDescription(
+                                "Select a message template to send in this channel"
+                            )
+                            .setFooter({
+                                text: enabled
+                                    ? ""
+                                    : "Tickets are not set up correctly so the button may not work for users. Check the main menu to find which options must be set."
+                            })
+                            .setStatus(enabled ? "Success" : "Warning")
+                            .setEmoji("GUILD.ROLES.CREATE")
+                    ],
+                    components: [
+                        new MessageActionRow().addComponents([
+                            new MessageSelectMenu()
+                                .setOptions(
+                                    ticketMessages.map(
+                                        (
+                                            t: {
+                                                label: string;
+                                                description: string;
+                                                value?: string;
+                                            },
+                                            index
+                                        ) => {
+                                            t.value = index.toString();
+                                            return t as {
+                                                value: string;
+                                                label: string;
+                                                description: string;
+                                            };
+                                        }
+                                    )
+                                )
+                                .setCustomId("template")
+                                .setMaxValues(1)
+                                .setMinValues(1)
+                                .setPlaceholder("Select a message template")
+                        ]),
+                        new MessageActionRow().addComponents([
+                            new MessageButton()
+                                .setCustomId("back")
+                                .setLabel("Back")
+                                .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+                                .setStyle("DANGER"),
+                            new MessageButton()
+                                .setCustomId("blank")
+                                .setLabel("Empty")
+                                .setStyle("SECONDARY"),
+                            new MessageButton()
+                                .setCustomId("custom")
+                                .setLabel("Custom")
+                                .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
+                                .setStyle("PRIMARY")
+                        ])
+                    ]
+                });
                 let i: MessageComponentInteraction;
                 try {
-                    i = await m.awaitMessageComponent({time: 300000});
-                } catch(e) { break; }
-                if ((i.component as MessageActionRowComponent).customId === "template") {
-                    i.deferUpdate();
-                    await interaction.channel.send({embeds: [new EmojiEmbed()
-                        .setTitle(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
-                        .setDescription(ticketMessages[parseInt((i as SelectMenuInteraction).values[0])].description)
-                        .setStatus("Success")
-                        .setEmoji("GUILD.TICKET.OPEN")
-                    ], components: [new MessageActionRow().addComponents([new MessageButton()
-                        .setLabel("Create Ticket")
-                        .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
-                        .setStyle("SUCCESS")
-                        .setCustomId("createticket")
-                    ])]});
+                    i = await m.awaitMessageComponent({ time: 300000 });
+                } catch (e) {
                     break;
-                } else if ((i.component as MessageActionRowComponent).customId === "blank") {
+                }
+                if (
+                    (i.component as MessageActionRowComponent).customId ===
+                    "template"
+                ) {
                     i.deferUpdate();
-                    await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
-                        .setLabel("Create Ticket")
-                        .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
-                        .setStyle("SUCCESS")
-                        .setCustomId("createticket")
-                    ])]});
+                    await interaction.channel.send({
+                        embeds: [
+                            new EmojiEmbed()
+                                .setTitle(
+                                    ticketMessages[
+                                        parseInt(
+                                            (i as SelectMenuInteraction)
+                                                .values[0]
+                                        )
+                                    ].label
+                                )
+                                .setDescription(
+                                    ticketMessages[
+                                        parseInt(
+                                            (i as SelectMenuInteraction)
+                                                .values[0]
+                                        )
+                                    ].description
+                                )
+                                .setStatus("Success")
+                                .setEmoji("GUILD.TICKET.OPEN")
+                        ],
+                        components: [
+                            new MessageActionRow().addComponents([
+                                new MessageButton()
+                                    .setLabel("Create Ticket")
+                                    .setEmoji(
+                                        getEmojiByName("CONTROL.TICK", "id")
+                                    )
+                                    .setStyle("SUCCESS")
+                                    .setCustomId("createticket")
+                            ])
+                        ]
+                    });
                     break;
-                } else if ((i.component as MessageActionRowComponent).customId === "custom") {
-                    await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
-                        new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                            .setCustomId("title")
-                            .setLabel("Title")
-                            .setMaxLength(256)
-                            .setRequired(true)
-                            .setStyle("SHORT")
-                        ),
-                        new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                            .setCustomId("description")
-                            .setLabel("Description")
-                            .setMaxLength(4000)
-                            .setRequired(true)
-                            .setStyle("PARAGRAPH")
-                        )
-                    ));
+                } else if (
+                    (i.component as MessageActionRowComponent).customId ===
+                    "blank"
+                ) {
+                    i.deferUpdate();
+                    await interaction.channel.send({
+                        components: [
+                            new MessageActionRow().addComponents([
+                                new MessageButton()
+                                    .setLabel("Create Ticket")
+                                    .setEmoji(
+                                        getEmojiByName(
+                                            "TICKETS.SUGGESTION",
+                                            "id"
+                                        )
+                                    )
+                                    .setStyle("SUCCESS")
+                                    .setCustomId("createticket")
+                            ])
+                        ]
+                    });
+                    break;
+                } else if (
+                    (i.component as MessageActionRowComponent).customId ===
+                    "custom"
+                ) {
+                    await i.showModal(
+                        new Discord.Modal()
+                            .setCustomId("modal")
+                            .setTitle("Enter embed details")
+                            .addComponents(
+                                new MessageActionRow<TextInputComponent>().addComponents(
+                                    new TextInputComponent()
+                                        .setCustomId("title")
+                                        .setLabel("Title")
+                                        .setMaxLength(256)
+                                        .setRequired(true)
+                                        .setStyle("SHORT")
+                                ),
+                                new MessageActionRow<TextInputComponent>().addComponents(
+                                    new TextInputComponent()
+                                        .setCustomId("description")
+                                        .setLabel("Description")
+                                        .setMaxLength(4000)
+                                        .setRequired(true)
+                                        .setStyle("PARAGRAPH")
+                                )
+                            )
+                    );
                     await interaction.editReply({
-                        embeds: [new EmojiEmbed()
-                            .setTitle("Ticket Button")
-                            .setDescription("Modal opened. If you can't see it, click back and try again.")
-                            .setStatus("Success")
-                            .setEmoji("GUILD.TICKET.OPEN")
-                        ], components: [new MessageActionRow().addComponents([new MessageButton()
-                            .setLabel("Back")
-                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                            .setStyle("PRIMARY")
-                            .setCustomId("back")
-                        ])]
+                        embeds: [
+                            new EmojiEmbed()
+                                .setTitle("Ticket Button")
+                                .setDescription(
+                                    "Modal opened. If you can't see it, click back and try again."
+                                )
+                                .setStatus("Success")
+                                .setEmoji("GUILD.TICKET.OPEN")
+                        ],
+                        components: [
+                            new MessageActionRow().addComponents([
+                                new MessageButton()
+                                    .setLabel("Back")
+                                    .setEmoji(
+                                        getEmojiByName("CONTROL.LEFT", "id")
+                                    )
+                                    .setStyle("PRIMARY")
+                                    .setCustomId("back")
+                            ])
+                        ]
                     });
                     let out;
                     try {
-                        out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
-                    } catch (e) { break; }
+                        out = await modalInteractionCollector(
+                            m,
+                            (m) => m.channel.id === interaction.channel.id,
+                            (m) => m.customId === "modify"
+                        );
+                    } catch (e) {
+                        break;
+                    }
                     if (out.fields) {
                         const title = out.fields.getTextInputValue("title");
-                        const description = out.fields.getTextInputValue("description");
-                        await interaction.channel.send({embeds: [new EmojiEmbed()
-                            .setTitle(title)
-                            .setDescription(description)
-                            .setStatus("Success")
-                            .setEmoji("GUILD.TICKET.OPEN")
-                        ], components: [new MessageActionRow().addComponents([new MessageButton()
-                            .setLabel("Create Ticket")
-                            .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
-                            .setStyle("SUCCESS")
-                            .setCustomId("createticket")
-                        ])]});
+                        const description =
+                            out.fields.getTextInputValue("description");
+                        await interaction.channel.send({
+                            embeds: [
+                                new EmojiEmbed()
+                                    .setTitle(title)
+                                    .setDescription(description)
+                                    .setStatus("Success")
+                                    .setEmoji("GUILD.TICKET.OPEN")
+                            ],
+                            components: [
+                                new MessageActionRow().addComponents([
+                                    new MessageButton()
+                                        .setLabel("Create Ticket")
+                                        .setEmoji(
+                                            getEmojiByName(
+                                                "TICKETS.SUGGESTION",
+                                                "id"
+                                            )
+                                        )
+                                        .setStyle("SUCCESS")
+                                        .setCustomId("createticket")
+                                ])
+                            ]
+                        });
                         break;
-                    } else { continue; }
+                    } else {
+                        continue;
+                    }
                 }
             }
-        } else if ((i.component as MessageActionRowComponent).customId === "enabled") {
-            await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled });
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "enabled"
+        ) {
+            await client.database.guilds.write(interaction.guild.id, {
+                "tickets.enabled": !data.enabled
+            });
             data.enabled = !data.enabled;
-        } else if ((i.component as MessageActionRowComponent).customId === "manageTypes") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId ===
+            "manageTypes"
+        ) {
             data = await manageTypes(interaction, data, m as Message);
         } else {
             break;
         }
     }
-    await interaction.editReply({ embeds: [embed.setFooter({ text: "Message closed" })], components: [] });
+    await interaction.editReply({
+        embeds: [embed.setFooter({ text: "Message closed" })],
+        components: []
+    });
 };
 
-async function manageTypes(interaction: CommandInteraction, data: GuildConfig["tickets"], m: Message) {
+async function manageTypes(
+    interaction: CommandInteraction,
+    data: GuildConfig["tickets"],
+    m: Message
+) {
     while (true) {
         if (data.useCustom) {
             const customTypes = data.customTypes;
             await interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets > Types")
-                    .setDescription(
-                        "**Custom types enabled**\n\n" +
-                        "**Types in use:**\n" + ((customTypes !== null) ?
-                            (customTypes.map((t) => `> ${t}`).join("\n")) :
-                            "*None set*"
-                        ) + "\n\n" + (customTypes === null ?
-                            `${getEmojiByName("TICKETS.REPORT")} Having no types will disable tickets. Please add at least 1 type or use default types` : ""
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Tickets > Types")
+                        .setDescription(
+                            "**Custom types enabled**\n\n" +
+                                "**Types in use:**\n" +
+                                (customTypes !== null
+                                    ? customTypes
+                                          .map((t) => `> ${t}`)
+                                          .join("\n")
+                                    : "*None set*") +
+                                "\n\n" +
+                                (customTypes === null
+                                    ? `${getEmojiByName(
+                                          "TICKETS.REPORT"
+                                      )} Having no types will disable tickets. Please add at least 1 type or use default types`
+                                    : "")
                         )
-                    )
-                    .setStatus("Success")
-                    .setEmoji("GUILD.TICKET.OPEN")
-                ], components: (customTypes ? [
-                    new MessageActionRow().addComponents([new Discord.MessageSelectMenu()
-                        .setCustomId("removeTypes")
-                        .setPlaceholder("Select types to remove")
-                        .setMaxValues(customTypes.length)
-                        .setMinValues(1)
-                        .addOptions(customTypes.map((t) => ({
-                            label: t,
-                            value: t
-                        })))
-                    ])
-                ] : []).concat([
+                        .setStatus("Success")
+                        .setEmoji("GUILD.TICKET.OPEN")
+                ],
+                components: (customTypes
+                    ? [
+                          new MessageActionRow().addComponents([
+                              new Discord.MessageSelectMenu()
+                                  .setCustomId("removeTypes")
+                                  .setPlaceholder("Select types to remove")
+                                  .setMaxValues(customTypes.length)
+                                  .setMinValues(1)
+                                  .addOptions(
+                                      customTypes.map((t) => ({
+                                          label: t,
+                                          value: t
+                                      }))
+                                  )
+                          ])
+                      ]
+                    : []
+                ).concat([
                     new MessageActionRow().addComponents([
                         new MessageButton()
                             .setLabel("Back")
@@ -387,10 +712,14 @@
                             .setCustomId("back"),
                         new MessageButton()
                             .setLabel("Add new type")
-                            .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+                            .setEmoji(
+                                getEmojiByName("TICKETS.SUGGESTION", "id")
+                            )
                             .setStyle("PRIMARY")
                             .setCustomId("addType")
-                            .setDisabled(customTypes !== null && customTypes.length >= 25),
+                            .setDisabled(
+                                customTypes !== null && customTypes.length >= 25
+                            ),
                         new MessageButton()
                             .setLabel("Switch to default types")
                             .setStyle("SECONDARY")
@@ -401,13 +730,20 @@
         } else {
             const inUse = toHexArray(data.types, ticketTypes);
             const options = [];
-            ticketTypes.forEach(type => {
-                options.push(new SelectMenuOption({
-                    label: capitalize(type),
-                    value: type,
-                    emoji: client.emojis.cache.get(getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")),
-                    default: inUse.includes(type)
-                }));
+            ticketTypes.forEach((type) => {
+                options.push(
+                    new SelectMenuOption({
+                        label: capitalize(type),
+                        value: type,
+                        emoji: client.emojis.cache.get(
+                            getEmojiByName(
+                                `TICKETS.${type.toUpperCase()}`,
+                                "id"
+                            )
+                        ),
+                        default: inUse.includes(type)
+                    })
+                );
             });
             const selectPane = new MessageActionRow().addComponents([
                 new Discord.MessageSelectMenu()
@@ -418,16 +754,25 @@
                     .setPlaceholder("Select types to use")
             ]);
             await interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets > Types")
-                    .setDescription(
-                        "**Default types enabled**\n\n" +
-                        "**Types in use:**\n" +
-                        (inUse.map((t) => `> ${getEmojiByName("TICKETS." + t.toUpperCase())} ${capitalize(t)}`).join("\n"))
-                    )
-                    .setStatus("Success")
-                    .setEmoji("GUILD.TICKET.OPEN")
-                ], components: [
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Tickets > Types")
+                        .setDescription(
+                            "**Default types enabled**\n\n" +
+                                "**Types in use:**\n" +
+                                inUse
+                                    .map(
+                                        (t) =>
+                                            `> ${getEmojiByName(
+                                                "TICKETS." + t.toUpperCase()
+                                            )} ${capitalize(t)}`
+                                    )
+                                    .join("\n")
+                        )
+                        .setStatus("Success")
+                        .setEmoji("GUILD.TICKET.OPEN")
+                ],
+                components: [
                     selectPane,
                     new MessageActionRow().addComponents([
                         new MessageButton()
@@ -446,11 +791,15 @@
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { break; }
+        } catch (e) {
+            break;
+        }
         if (i.component.customId === "types") {
             i.deferUpdate();
             const types = toHexInteger(i.values, ticketTypes);
-            await client.database.guilds.write(interaction.guild.id, { "tickets.types": types });
+            await client.database.guilds.write(interaction.guild.id, {
+                "tickets.types": types
+            });
             data.types = types;
         } else if (i.component.customId === "removeTypes") {
             i.deferUpdate();
@@ -459,57 +808,96 @@
             if (customTypes) {
                 customTypes = customTypes.filter((t) => !types.includes(t));
                 customTypes = customTypes.length > 0 ? customTypes : null;
-                await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes });
+                await client.database.guilds.write(interaction.guild.id, {
+                    "tickets.customTypes": customTypes
+                });
                 data.customTypes = customTypes;
             }
         } else if (i.component.customId === "addType") {
-            await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter a name for the new type").addComponents(
-                new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                    .setCustomId("type")
-                    .setLabel("Name")
-                    .setMaxLength(100)
-                    .setMinLength(1)
-                    .setPlaceholder("E.g. \"Server Idea\"")
-                    .setRequired(true)
-                    .setStyle("SHORT")
-                )
-            ));
+            await i.showModal(
+                new Discord.Modal()
+                    .setCustomId("modal")
+                    .setTitle("Enter a name for the new type")
+                    .addComponents(
+                        new MessageActionRow<TextInputComponent>().addComponents(
+                            new TextInputComponent()
+                                .setCustomId("type")
+                                .setLabel("Name")
+                                .setMaxLength(100)
+                                .setMinLength(1)
+                                .setPlaceholder('E.g. "Server Idea"')
+                                .setRequired(true)
+                                .setStyle("SHORT")
+                        )
+                    )
+            );
             await interaction.editReply({
-                embeds: [new EmojiEmbed()
-                    .setTitle("Tickets > Types")
-                    .setDescription("Modal opened. If you can't see it, click back and try again.")
-                    .setStatus("Success")
-                    .setEmoji("GUILD.TICKET.OPEN")
-                ], components: [new MessageActionRow().addComponents([new MessageButton()
-                    .setLabel("Back")
-                    .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                    .setStyle("PRIMARY")
-                    .setCustomId("back")
-                ])]
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Tickets > Types")
+                        .setDescription(
+                            "Modal opened. If you can't see it, click back and try again."
+                        )
+                        .setStatus("Success")
+                        .setEmoji("GUILD.TICKET.OPEN")
+                ],
+                components: [
+                    new MessageActionRow().addComponents([
+                        new MessageButton()
+                            .setLabel("Back")
+                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+                            .setStyle("PRIMARY")
+                            .setCustomId("back")
+                    ])
+                ]
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType");
-            } catch (e) { continue; }
+                out = await modalInteractionCollector(
+                    m,
+                    (m) => m.channel.id === interaction.channel.id,
+                    (m) => m.customId === "addType"
+                );
+            } catch (e) {
+                continue;
+            }
             if (out.fields) {
                 let toAdd = out.fields.getTextInputValue("type");
-                if (!toAdd) { continue; }
+                if (!toAdd) {
+                    continue;
+                }
                 toAdd = toAdd.substring(0, 80);
                 try {
-                    await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd);
-                } catch { continue; }
+                    await client.database.guilds.append(
+                        interaction.guild.id,
+                        "tickets.customTypes",
+                        toAdd
+                    );
+                } catch {
+                    continue;
+                }
                 data.customTypes = data.customTypes || [];
                 if (!data.customTypes.includes(toAdd)) {
                     data.customTypes.push(toAdd);
                 }
-            } else { continue; }
+            } else {
+                continue;
+            }
         } else if (i.component.customId === "switchToDefault") {
             i.deferUpdate();
-            await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, []);
+            await client.database.guilds.write(
+                interaction.guild.id,
+                { "tickets.useCustom": false },
+                []
+            );
             data.useCustom = false;
         } else if (i.component.customId === "switchToCustom") {
             i.deferUpdate();
-            await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, []);
+            await client.database.guilds.write(
+                interaction.guild.id,
+                { "tickets.useCustom": true },
+                []
+            );
             data.useCustom = true;
         } else {
             i.deferUpdate();
@@ -519,10 +907,10 @@
     return data;
 }
 
-
 const check = (interaction: CommandInteraction) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index 4efd68c..e0af802 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,5 +1,17 @@
 import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, Message, MessageActionRow, MessageActionRowComponent, MessageButton, MessageComponentInteraction, MessageEmbed, MessageSelectMenu, Role, SelectMenuInteraction, TextInputComponent } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    Message,
+    MessageActionRow,
+    MessageActionRowComponent,
+    MessageButton,
+    MessageComponentInteraction,
+    MessageEmbed,
+    MessageSelectMenu,
+    Role,
+    SelectMenuInteraction,
+    TextInputComponent
+} from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -11,45 +23,70 @@
     builder
         .setName("verify")
         .setDescription("Manage the role given after typing /verify")
-        .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying").setRequired(false));
+        .addRoleOption((option) =>
+            option
+                .setName("role")
+                .setDescription("The role to give after verifying")
+                .setRequired(false)
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Message;
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    const m = (await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    })) as Message;
     if (interaction.options.getRole("role")) {
         let role: Role;
         try {
             role = interaction.options.getRole("role") as Role;
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("GUILD.ROLES.DELETE")
-                .setTitle("Verify Role")
-                .setDescription("The role you provided is not a valid role")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("GUILD.ROLES.DELETE")
+                        .setTitle("Verify Role")
+                        .setDescription(
+                            "The role you provided is not a valid role"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         role = role as Discord.Role;
         if (role.guild.id !== interaction.guild.id) {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Verify Role")
-                .setDescription("You must choose a role in this server")
-                .setStatus("Danger")
-                .setEmoji("GUILD.ROLES.DELETE")
-            ]});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Verify Role")
+                        .setDescription("You must choose a role in this server")
+                        .setStatus("Danger")
+                        .setEmoji("GUILD.ROLES.DELETE")
+                ]
+            });
         }
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.ROLES.EDIT")
             .setTitle("Verify Role")
-            .setDescription(`Are you sure you want to set the verify role to <@&${role.id}>?`)
+            .setDescription(
+                `Are you sure you want to set the verify role to <@&${role.id}>?`
+            )
             .setColor("Warning")
             .setInverted(true)
             .send(true);
         if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
-                const { log, NucleusColors, entry, renderUser, renderRole } = client.logger;
+                await client.database.guilds.write(interaction.guild.id, {
+                    "verify.role": role.id,
+                    "verify.enabled": true
+                });
+                const { log, NucleusColors, entry, renderUser, renderRole } =
+                    client.logger;
                 const data = {
-                    meta:{
+                    meta: {
                         type: "verifyRoleChanged",
                         displayName: "Verify Role Changed",
                         calculateType: "nucleusSettingsUpdated",
@@ -58,8 +95,14 @@
                         timestamp: new Date().getTime()
                     },
                     list: {
-                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        memberId: entry(
+                            interaction.user.id,
+                            `\`${interaction.user.id}\``
+                        ),
+                        changedBy: entry(
+                            interaction.user.id,
+                            renderUser(interaction.user)
+                        ),
                         role: entry(role.id, renderRole(role))
                     },
                     hidden: {
@@ -69,169 +112,319 @@
                 log(data);
             } catch (e) {
                 console.log(e);
-                return interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Verify Role")
-                    .setDescription("Something went wrong while setting the verify role")
-                    .setStatus("Danger")
-                    .setEmoji("GUILD.ROLES.DELETE")
-                ], components: []});
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Verify Role")
+                            .setDescription(
+                                "Something went wrong while setting the verify role"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("GUILD.ROLES.DELETE")
+                    ],
+                    components: []
+                });
             }
         } else {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Verify Role")
-                .setDescription("No changes were made")
-                .setStatus("Success")
-                .setEmoji("GUILD.ROLES.CREATE")
-            ], components: []});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Verify Role")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("GUILD.ROLES.CREATE")
+                ],
+                components: []
+            });
         }
     }
     let clicks = 0;
     const data = await client.database.guilds.read(interaction.guild.id);
     let role = data.verify.role;
     while (true) {
-        await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Verify Role")
-            .setDescription(role ? `Your verify role is currently set to <@&${role}>` : "You have not set a verify role")
-            .setStatus("Success")
-            .setEmoji("GUILD.ROLES.CREATE")
-        ], components: [new MessageActionRow().addComponents([
-            new MessageButton()
-                .setCustomId("clear")
-                .setLabel(clicks ? "Click again to confirm" : "Reset role")
-                .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
-                .setStyle("DANGER")
-                .setDisabled(!role),
-            new MessageButton()
-                .setCustomId("send")
-                .setLabel("Add verify button")
-                .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
-                .setStyle("PRIMARY")
-        ])]});
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Verify Role")
+                    .setDescription(
+                        role
+                            ? `Your verify role is currently set to <@&${role}>`
+                            : "You have not set a verify role"
+                    )
+                    .setStatus("Success")
+                    .setEmoji("GUILD.ROLES.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setCustomId("clear")
+                        .setLabel(
+                            clicks ? "Click again to confirm" : "Reset role"
+                        )
+                        .setEmoji(
+                            getEmojiByName(
+                                clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+                                "id"
+                            )
+                        )
+                        .setStyle("DANGER")
+                        .setDisabled(!role),
+                    new MessageButton()
+                        .setCustomId("send")
+                        .setLabel("Add verify button")
+                        .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+                        .setStyle("PRIMARY")
+                ])
+            ]
+        });
         let i: MessageComponentInteraction;
         try {
-            i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break; }
+            i = await m.awaitMessageComponent({ time: 300000 });
+        } catch (e) {
+            break;
+        }
         i.deferUpdate();
         if ((i.component as MessageActionRowComponent).customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]);
+                await client.database.guilds.write(interaction.guild.id, null, [
+                    "verify.role",
+                    "verify.enabled"
+                ]);
                 role = undefined;
             }
-        } else if ((i.component as MessageActionRowComponent).customId === "send") {
+        } else if (
+            (i.component as MessageActionRowComponent).customId === "send"
+        ) {
             const verifyMessages = [
-                {label: "Verify", description: "Click the button below to get verified"},
-                {label: "Get verified", description: "To get access to the rest of the server, click the button below"},
-                {label: "Ready to verify?", description: "Click the button below to verify yourself"}
+                {
+                    label: "Verify",
+                    description: "Click the button below to get verified"
+                },
+                {
+                    label: "Get verified",
+                    description:
+                        "To get access to the rest of the server, click the button below"
+                },
+                {
+                    label: "Ready to verify?",
+                    description: "Click the button below to verify yourself"
+                }
             ];
             while (true) {
-                await interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Verify Button")
-                    .setDescription("Select a message template to send in this channel")
-                    .setFooter({text: role ? "" : "You do no have a verify role set so the button will not work."})
-                    .setStatus(role ? "Success" : "Warning")
-                    .setEmoji("GUILD.ROLES.CREATE")
-                ], components: [
-                    new MessageActionRow().addComponents([
-                        new MessageSelectMenu().setOptions(verifyMessages.map((t: {label: string, description: string, value?: string}, index) => {
-                            t.value = index.toString(); return t as {value: string, label: string, description: string};
-                        })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
-                    ]),
-                    new MessageActionRow().addComponents([
-                        new MessageButton()
-                            .setCustomId("back")
-                            .setLabel("Back")
-                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                            .setStyle("DANGER"),
-                        new MessageButton()
-                            .setCustomId("blank")
-                            .setLabel("Empty")
-                            .setStyle("SECONDARY"),
-                        new MessageButton()
-                            .setCustomId("custom")
-                            .setLabel("Custom")
-                            .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
-                            .setStyle("PRIMARY")
-                    ])
-                ]});
+                await interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Verify Button")
+                            .setDescription(
+                                "Select a message template to send in this channel"
+                            )
+                            .setFooter({
+                                text: role
+                                    ? ""
+                                    : "You do no have a verify role set so the button will not work."
+                            })
+                            .setStatus(role ? "Success" : "Warning")
+                            .setEmoji("GUILD.ROLES.CREATE")
+                    ],
+                    components: [
+                        new MessageActionRow().addComponents([
+                            new MessageSelectMenu()
+                                .setOptions(
+                                    verifyMessages.map(
+                                        (
+                                            t: {
+                                                label: string;
+                                                description: string;
+                                                value?: string;
+                                            },
+                                            index
+                                        ) => {
+                                            t.value = index.toString();
+                                            return t as {
+                                                value: string;
+                                                label: string;
+                                                description: string;
+                                            };
+                                        }
+                                    )
+                                )
+                                .setCustomId("template")
+                                .setMaxValues(1)
+                                .setMinValues(1)
+                                .setPlaceholder("Select a message template")
+                        ]),
+                        new MessageActionRow().addComponents([
+                            new MessageButton()
+                                .setCustomId("back")
+                                .setLabel("Back")
+                                .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
+                                .setStyle("DANGER"),
+                            new MessageButton()
+                                .setCustomId("blank")
+                                .setLabel("Empty")
+                                .setStyle("SECONDARY"),
+                            new MessageButton()
+                                .setCustomId("custom")
+                                .setLabel("Custom")
+                                .setEmoji(getEmojiByName("TICKETS.OTHER", "id"))
+                                .setStyle("PRIMARY")
+                        ])
+                    ]
+                });
                 let i: MessageComponentInteraction;
                 try {
-                    i = await m.awaitMessageComponent({time: 300000});
-                } catch(e) { break; }
-                if ((i.component as MessageActionRowComponent).customId === "template") {
-                    i.deferUpdate();
-                    await interaction.channel.send({embeds: [new EmojiEmbed()
-                        .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
-                        .setDescription(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].description)
-                        .setStatus("Success")
-                        .setEmoji("CONTROL.BLOCKTICK")
-                    ], components: [new MessageActionRow().addComponents([new MessageButton()
-                        .setLabel("Verify")
-                        .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
-                        .setStyle("SUCCESS")
-                        .setCustomId("verifybutton")
-                    ])]});
+                    i = await m.awaitMessageComponent({ time: 300000 });
+                } catch (e) {
                     break;
-                } else if ((i.component as MessageActionRowComponent).customId === "blank") {
+                }
+                if (
+                    (i.component as MessageActionRowComponent).customId ===
+                    "template"
+                ) {
                     i.deferUpdate();
-                    await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
-                        .setLabel("Verify")
-                        .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
-                        .setStyle("SUCCESS")
-                        .setCustomId("verifybutton")
-                    ])]});
+                    await interaction.channel.send({
+                        embeds: [
+                            new EmojiEmbed()
+                                .setTitle(
+                                    verifyMessages[
+                                        parseInt(
+                                            (i as SelectMenuInteraction)
+                                                .values[0]
+                                        )
+                                    ].label
+                                )
+                                .setDescription(
+                                    verifyMessages[
+                                        parseInt(
+                                            (i as SelectMenuInteraction)
+                                                .values[0]
+                                        )
+                                    ].description
+                                )
+                                .setStatus("Success")
+                                .setEmoji("CONTROL.BLOCKTICK")
+                        ],
+                        components: [
+                            new MessageActionRow().addComponents([
+                                new MessageButton()
+                                    .setLabel("Verify")
+                                    .setEmoji(
+                                        getEmojiByName("CONTROL.TICK", "id")
+                                    )
+                                    .setStyle("SUCCESS")
+                                    .setCustomId("verifybutton")
+                            ])
+                        ]
+                    });
                     break;
-                } else if ((i.component as MessageActionRowComponent).customId === "custom") {
-                    await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
-                        new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                            .setCustomId("title")
-                            .setLabel("Title")
-                            .setMaxLength(256)
-                            .setRequired(true)
-                            .setStyle("SHORT")
-                        ),
-                        new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
-                            .setCustomId("description")
-                            .setLabel("Description")
-                            .setMaxLength(4000)
-                            .setRequired(true)
-                            .setStyle("PARAGRAPH")
-                        )
-                    ));
+                } else if (
+                    (i.component as MessageActionRowComponent).customId ===
+                    "blank"
+                ) {
+                    i.deferUpdate();
+                    await interaction.channel.send({
+                        components: [
+                            new MessageActionRow().addComponents([
+                                new MessageButton()
+                                    .setLabel("Verify")
+                                    .setEmoji(
+                                        getEmojiByName("CONTROL.TICK", "id")
+                                    )
+                                    .setStyle("SUCCESS")
+                                    .setCustomId("verifybutton")
+                            ])
+                        ]
+                    });
+                    break;
+                } else if (
+                    (i.component as MessageActionRowComponent).customId ===
+                    "custom"
+                ) {
+                    await i.showModal(
+                        new Discord.Modal()
+                            .setCustomId("modal")
+                            .setTitle("Enter embed details")
+                            .addComponents(
+                                new MessageActionRow<TextInputComponent>().addComponents(
+                                    new TextInputComponent()
+                                        .setCustomId("title")
+                                        .setLabel("Title")
+                                        .setMaxLength(256)
+                                        .setRequired(true)
+                                        .setStyle("SHORT")
+                                ),
+                                new MessageActionRow<TextInputComponent>().addComponents(
+                                    new TextInputComponent()
+                                        .setCustomId("description")
+                                        .setLabel("Description")
+                                        .setMaxLength(4000)
+                                        .setRequired(true)
+                                        .setStyle("PARAGRAPH")
+                                )
+                            )
+                    );
                     await interaction.editReply({
-                        embeds: [new EmojiEmbed()
-                            .setTitle("Verify Button")
-                            .setDescription("Modal opened. If you can't see it, click back and try again.")
-                            .setStatus("Success")
-                            .setEmoji("GUILD.TICKET.OPEN")
-                        ], components: [new MessageActionRow().addComponents([new MessageButton()
-                            .setLabel("Back")
-                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
-                            .setStyle("PRIMARY")
-                            .setCustomId("back")
-                        ])]
+                        embeds: [
+                            new EmojiEmbed()
+                                .setTitle("Verify Button")
+                                .setDescription(
+                                    "Modal opened. If you can't see it, click back and try again."
+                                )
+                                .setStatus("Success")
+                                .setEmoji("GUILD.TICKET.OPEN")
+                        ],
+                        components: [
+                            new MessageActionRow().addComponents([
+                                new MessageButton()
+                                    .setLabel("Back")
+                                    .setEmoji(
+                                        getEmojiByName("CONTROL.LEFT", "id")
+                                    )
+                                    .setStyle("PRIMARY")
+                                    .setCustomId("back")
+                            ])
+                        ]
                     });
                     let out;
                     try {
-                        out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
-                    } catch (e) { break; }
+                        out = await modalInteractionCollector(
+                            m,
+                            (m) => m.channel.id === interaction.channel.id,
+                            (m) => m.customId === "modify"
+                        );
+                    } catch (e) {
+                        break;
+                    }
                     if (out.fields) {
                         const title = out.fields.getTextInputValue("title");
-                        const description = out.fields.getTextInputValue("description");
-                        await interaction.channel.send({embeds: [new EmojiEmbed()
-                            .setTitle(title)
-                            .setDescription(description)
-                            .setStatus("Success")
-                            .setEmoji("CONTROL.BLOCKTICK")
-                        ], components: [new MessageActionRow().addComponents([new MessageButton()
-                            .setLabel("Verify")
-                            .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
-                            .setStyle("SUCCESS")
-                            .setCustomId("verifybutton")
-                        ])]});
+                        const description =
+                            out.fields.getTextInputValue("description");
+                        await interaction.channel.send({
+                            embeds: [
+                                new EmojiEmbed()
+                                    .setTitle(title)
+                                    .setDescription(description)
+                                    .setStatus("Success")
+                                    .setEmoji("CONTROL.BLOCKTICK")
+                            ],
+                            components: [
+                                new MessageActionRow().addComponents([
+                                    new MessageButton()
+                                        .setLabel("Verify")
+                                        .setEmoji(
+                                            getEmojiByName("CONTROL.TICK", "id")
+                                        )
+                                        .setStyle("SUCCESS")
+                                        .setCustomId("verifybutton")
+                                ])
+                            ]
+                        });
                         break;
-                    } else { continue; }
+                    } else {
+                        continue;
+                    }
                 }
             }
         } else {
@@ -239,12 +432,16 @@
             break;
         }
     }
-    await interaction.editReply({embeds: [(m.embeds[0] as MessageEmbed).setFooter({text: "Message closed"})], components: []});
+    await interaction.editReply({
+        embeds: [m.embeds[0]!.setFooter({ text: "Message closed" })],
+        components: []
+    });
 };
 
 const check = (interaction: CommandInteraction) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index f22f409..3eb0ec5 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -1,5 +1,13 @@
 import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, { Channel, CommandInteraction, Message, MessageActionRow, MessageButton, MessageComponentInteraction, Role } from "discord.js";
+import Discord, {
+    Channel,
+    CommandInteraction,
+    Message,
+    MessageActionRow,
+    MessageButton,
+    MessageComponentInteraction,
+    Role
+} from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import client from "../../utils/client.js";
@@ -11,19 +19,52 @@
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
         .setName("welcome")
-        .setDescription("Messages and roles sent or given when someone joins the server")
-        .addStringOption(option => option.setName("message").setDescription("The message to send when someone joins the server").setAutocomplete(true))
-        .addRoleOption(option => option.setName("role").setDescription("The role given when someone joins the server"))
-        .addRoleOption(option => option.setName("ping").setDescription("The role pinged when someone joins the server"))
-        .addChannelOption(option => option.setName("channel").setDescription("The channel the welcome message should be sent to").addChannelTypes([
-            ChannelType.GuildText, ChannelType.GuildNews
-        ]));
+        .setDescription(
+            "Messages and roles sent or given when someone joins the server"
+        )
+        .addStringOption((option) =>
+            option
+                .setName("message")
+                .setDescription(
+                    "The message to send when someone joins the server"
+                )
+                .setAutocomplete(true)
+        )
+        .addRoleOption((option) =>
+            option
+                .setName("role")
+                .setDescription("The role given when someone joins the server")
+        )
+        .addRoleOption((option) =>
+            option
+                .setName("ping")
+                .setDescription("The role pinged when someone joins the server")
+        )
+        .addChannelOption((option) =>
+            option
+                .setName("channel")
+                .setDescription(
+                    "The channel the welcome message should be sent to"
+                )
+                .addChannelTypes([ChannelType.GuildText, ChannelType.GuildNews])
+        );
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger;
-    await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } =
+        client.logger;
+    await interaction.reply({
+        embeds: LoadingEmbed,
+        fetchReply: true,
+        ephemeral: true
+    });
     let m: Message;
-    if (interaction.options.getRole("role") || interaction.options.getChannel("channel") || interaction.options.getString("message")) {
+    if (
+        interaction.options.getRole("role") ||
+        interaction.options.getChannel("channel") ||
+        interaction.options.getString("message")
+    ) {
         let role: Role;
         let ping: Role;
         const message = interaction.options.getString("message");
@@ -31,32 +72,42 @@
             role = interaction.options.getRole("role") as Role;
             ping = interaction.options.getRole("ping") as Role;
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("GUILD.ROLES.DELETE")
-                .setTitle("Welcome Events")
-                .setDescription("The role you provided is not a valid role")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("GUILD.ROLES.DELETE")
+                        .setTitle("Welcome Events")
+                        .setDescription(
+                            "The role you provided is not a valid role"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         let channel: Channel;
         try {
             channel = interaction.options.getChannel("channel") as Channel;
         } catch {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji("GUILD.ROLES.DELETE")
-                .setTitle("Welcome Events")
-                .setDescription("The channel you provided is not a valid channel")
-                .setStatus("Danger")
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setEmoji("GUILD.ROLES.DELETE")
+                        .setTitle("Welcome Events")
+                        .setDescription(
+                            "The channel you provided is not a valid channel"
+                        )
+                        .setStatus("Danger")
+                ]
+            });
         }
         role = role as Discord.Role;
         ping = ping as Discord.Role;
         channel = channel as Discord.TextChannel;
         const options = {};
-        if (role) options["role"] = renderRole(role);
-        if (ping) options["ping"] = renderRole(ping);
-        if (channel) options["channel"] = renderChannel(channel);
-        if (message) options["message"] = "\n> " + message;
+        if (role) options.role = renderRole(role);
+        if (ping) options.ping = renderRole(ping);
+        if (channel) options.channel = renderChannel(channel);
+        if (message) options.message = "\n> " + message;
         const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.ROLES.EDIT")
             .setTitle("Welcome Events")
@@ -72,17 +123,27 @@
                 if (ping) toChange["welcome.ping"] = ping.id;
                 if (channel) toChange["welcome.channel"] = channel.id;
                 if (message) toChange["welcome.message"] = message;
-                await client.database.guilds.write(interaction.guild.id, toChange);
+                await client.database.guilds.write(
+                    interaction.guild.id,
+                    toChange
+                );
                 const list = {
-                    memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                    changedBy: entry(interaction.user.id, renderUser(interaction.user))
+                    memberId: entry(
+                        interaction.user.id,
+                        `\`${interaction.user.id}\``
+                    ),
+                    changedBy: entry(
+                        interaction.user.id,
+                        renderUser(interaction.user)
+                    )
                 };
-                if (role) list["role"] = entry(role.id, renderRole(role));
-                if (ping) list["ping"] = entry(ping.id, renderRole(ping));
-                if (channel) list["channel"] = entry(channel.id, renderChannel(channel.id));
-                if (message) list["message"] = entry(message, `\`${message}\``);
+                if (role) list.role = entry(role.id, renderRole(role));
+                if (ping) list.ping = entry(ping.id, renderRole(ping));
+                if (channel)
+                    list.channel = entry(channel.id, renderChannel(channel.id));
+                if (message) list.message = entry(message, `\`${message}\``);
                 const data = {
-                    meta:{
+                    meta: {
                         type: "welcomeSettingsUpdated",
                         displayName: "Welcome Settings Changed",
                         calculateType: "nucleusSettingsUpdated",
@@ -98,68 +159,128 @@
                 log(data);
             } catch (e) {
                 console.log(e);
-                return interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Welcome Events")
-                    .setDescription("Something went wrong while updating welcome settings")
-                    .setStatus("Danger")
-                    .setEmoji("GUILD.ROLES.DELETE")
-                ], components: []});
+                return interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setTitle("Welcome Events")
+                            .setDescription(
+                                "Something went wrong while updating welcome settings"
+                            )
+                            .setStatus("Danger")
+                            .setEmoji("GUILD.ROLES.DELETE")
+                    ],
+                    components: []
+                });
             }
         } else {
-            return interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Welcome Events")
-                .setDescription("No changes were made")
-                .setStatus("Success")
-                .setEmoji("GUILD.ROLES.CREATE")
-            ], components: []});
+            return interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Welcome Events")
+                        .setDescription("No changes were made")
+                        .setStatus("Success")
+                        .setEmoji("GUILD.ROLES.CREATE")
+                ],
+                components: []
+            });
         }
     }
     let lastClicked = null;
     while (true) {
         const config = await client.database.guilds.read(interaction.guild.id);
-        m = await interaction.editReply({embeds: [new EmojiEmbed()
-            .setTitle("Welcome Events")
-            .setDescription(
-                `**Message:** ${config.welcome.message ? `\n> ${config.welcome.message}` : "*None set*"}\n` +
-                `**Role:** ${config.welcome.role ? renderRole(await interaction.guild.roles.fetch(config.welcome.role)) : "*None set*"}\n` +
-                `**Ping:** ${config.welcome.ping ? renderRole(await interaction.guild.roles.fetch(config.welcome.ping)) : "*None set*"}\n` +
-                `**Channel:** ${config.welcome.channel ? (config.welcome.channel == "dm" ? "DM" : renderChannel(await interaction.guild.channels.fetch(config.welcome.channel))) : "*None set*"}`
-            )
-            .setStatus("Success")
-            .setEmoji("CHANNEL.TEXT.CREATE")
-        ], components: [
-            new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setLabel(lastClicked == "clear-message" ? "Click again to confirm" : "Clear Message")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setCustomId("clear-message")
-                    .setDisabled(!config.welcome.message)
-                    .setStyle("DANGER"),
-                new MessageButton()
-                    .setLabel(lastClicked == "clear-role" ? "Click again to confirm" : "Clear Role")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setCustomId("clear-role")
-                    .setDisabled(!config.welcome.role)
-                    .setStyle("DANGER"),
-                new MessageButton()
-                    .setLabel(lastClicked == "clear-ping" ? "Click again to confirm" : "Clear Ping")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setCustomId("clear-ping")
-                    .setDisabled(!config.welcome.ping)
-                    .setStyle("DANGER"),
-                new MessageButton()
-                    .setLabel(lastClicked == "clear-channel" ? "Click again to confirm" : "Clear Channel")
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    .setCustomId("clear-channel")
-                    .setDisabled(!config.welcome.channel)
-                    .setStyle("DANGER"),
-                new MessageButton()
-                    .setLabel("Set Channel to DM")
-                    .setCustomId("set-channel-dm")
-                    .setDisabled(config.welcome.channel == "dm")
-                    .setStyle("SECONDARY")
-            ])
-        ]}) as Message;
+        m = (await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Welcome Events")
+                    .setDescription(
+                        `**Message:** ${
+                            config.welcome.message
+                                ? `\n> ${config.welcome.message}`
+                                : "*None set*"
+                        }\n` +
+                            `**Role:** ${
+                                config.welcome.role
+                                    ? renderRole(
+                                          await interaction.guild.roles.fetch(
+                                              config.welcome.role
+                                          )
+                                      )
+                                    : "*None set*"
+                            }\n` +
+                            `**Ping:** ${
+                                config.welcome.ping
+                                    ? renderRole(
+                                          await interaction.guild.roles.fetch(
+                                              config.welcome.ping
+                                          )
+                                      )
+                                    : "*None set*"
+                            }\n` +
+                            `**Channel:** ${
+                                config.welcome.channel
+                                    ? config.welcome.channel == "dm"
+                                        ? "DM"
+                                        : renderChannel(
+                                              await interaction.guild.channels.fetch(
+                                                  config.welcome.channel
+                                              )
+                                          )
+                                    : "*None set*"
+                            }`
+                    )
+                    .setStatus("Success")
+                    .setEmoji("CHANNEL.TEXT.CREATE")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked == "clear-message"
+                                ? "Click again to confirm"
+                                : "Clear Message"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setCustomId("clear-message")
+                        .setDisabled(!config.welcome.message)
+                        .setStyle("DANGER"),
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked == "clear-role"
+                                ? "Click again to confirm"
+                                : "Clear Role"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setCustomId("clear-role")
+                        .setDisabled(!config.welcome.role)
+                        .setStyle("DANGER"),
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked == "clear-ping"
+                                ? "Click again to confirm"
+                                : "Clear Ping"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setCustomId("clear-ping")
+                        .setDisabled(!config.welcome.ping)
+                        .setStyle("DANGER"),
+                    new MessageButton()
+                        .setLabel(
+                            lastClicked == "clear-channel"
+                                ? "Click again to confirm"
+                                : "Clear Channel"
+                        )
+                        .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+                        .setCustomId("clear-channel")
+                        .setDisabled(!config.welcome.channel)
+                        .setStyle("DANGER"),
+                    new MessageButton()
+                        .setLabel("Set Channel to DM")
+                        .setCustomId("set-channel-dm")
+                        .setDisabled(config.welcome.channel == "dm")
+                        .setStyle("SECONDARY")
+                ])
+            ]
+        })) as Message;
         let i: MessageComponentInteraction;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
@@ -169,35 +290,57 @@
         i.deferUpdate();
         if (i.customId == "clear-message") {
             if (lastClicked == "clear-message") {
-                await client.database.guilds.write(interaction.guild.id, {"welcome.message": null});
+                await client.database.guilds.write(interaction.guild.id, {
+                    "welcome.message": null
+                });
                 lastClicked = null;
-            } else { lastClicked = "clear-message"; }
+            } else {
+                lastClicked = "clear-message";
+            }
         } else if (i.customId == "clear-role") {
             if (lastClicked == "clear-role") {
-                await client.database.guilds.write(interaction.guild.id, {"welcome.role": null});
+                await client.database.guilds.write(interaction.guild.id, {
+                    "welcome.role": null
+                });
                 lastClicked = null;
-            } else { lastClicked = "clear-role"; }
+            } else {
+                lastClicked = "clear-role";
+            }
         } else if (i.customId == "clear-ping") {
             if (lastClicked == "clear-ping") {
-                await client.database.guilds.write(interaction.guild.id, {"welcome.ping": null});
+                await client.database.guilds.write(interaction.guild.id, {
+                    "welcome.ping": null
+                });
                 lastClicked = null;
-            } else { lastClicked = "clear-ping"; }
+            } else {
+                lastClicked = "clear-ping";
+            }
         } else if (i.customId == "clear-channel") {
             if (lastClicked == "clear-channel") {
-                await client.database.guilds.write(interaction.guild.id, {"welcome.channel": null});
+                await client.database.guilds.write(interaction.guild.id, {
+                    "welcome.channel": null
+                });
                 lastClicked = null;
-            } else { lastClicked = "clear-channel"; }
+            } else {
+                lastClicked = "clear-channel";
+            }
         } else if (i.customId == "set-channel-dm") {
-            await client.database.guilds.write(interaction.guild.id, {"welcome.channel": "dm"});
+            await client.database.guilds.write(interaction.guild.id, {
+                "welcome.channel": "dm"
+            });
             lastClicked = null;
         }
     }
-    await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
+    await interaction.editReply({
+        embeds: [m.embeds[0].setFooter({ text: "Message closed" })],
+        components: []
+    });
 };
 
 const check = (interaction: CommandInteraction) => {
-    const member = (interaction.member as Discord.GuildMember);
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+    const member = interaction.member as Discord.GuildMember;
+    if (!member.permissions.has("MANAGE_GUILD"))
+        throw "You must have the *Manage Server* permission to use this command";
     return true;
 };
 
