diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index b2d484c..bf52dd1 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -14,7 +14,7 @@
     ModalBuilder,
     TextInputBuilder,
     TextInputStyle,
-    ModalSubmitInteraction,
+    ModalSubmitInteraction
 } from "discord.js";
 import type { SlashCommandSubcommandBuilder } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -24,9 +24,7 @@
 import { modalInteractionCollector } from "../../utils/dualCollector.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
-    builder
-        .setName("welcome")
-        .setDescription("Messages and roles sent or given when someone joins the server")
+    builder.setName("welcome").setDescription("Messages and roles sent or given when someone joins the server");
 
 const callback = async (interaction: CommandInteraction): Promise<void> => {
     const { renderChannel } = client.logger;
@@ -39,80 +37,87 @@
     let config = await client.database.guilds.read(interaction.guild!.id);
     let data = Object.assign({}, config.welcome);
     do {
-        const buttons = new ActionRowBuilder<ButtonBuilder>()
-            .addComponents(
-                new ButtonBuilder()
-                    .setCustomId("switch")
-                    .setLabel(data.enabled ? "Enabled" : "Disabled")
-                    .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
-                    .setEmoji(getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji),
-                new ButtonBuilder()
-                    .setCustomId("message")
-                    .setLabel((data.message ? "Change" : "Set") + "Message")
-                    .setStyle(ButtonStyle.Primary)
-                    .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
-                new ButtonBuilder()
-                    .setCustomId("channelDM")
-                    .setLabel("Send in DMs")
-                    .setStyle(ButtonStyle.Primary)
-                    .setDisabled(data.channel === "dm"),
-                new ButtonBuilder()
-                    .setCustomId("role")
-                    .setLabel("Clear Role")
-                    .setStyle(ButtonStyle.Danger)
-                    .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji),
-                new ButtonBuilder()
-                    .setCustomId("save")
-                    .setLabel("Save")
-                    .setStyle(ButtonStyle.Success)
-                    .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
-                    .setDisabled(
-                        data.enabled === config.welcome.enabled &&
+        const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+            new ButtonBuilder()
+                .setCustomId("switch")
+                .setLabel(data.enabled ? "Enabled" : "Disabled")
+                .setStyle(data.enabled ? ButtonStyle.Success : ButtonStyle.Danger)
+                .setEmoji(
+                    getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS", "id") as APIMessageComponentEmoji
+                ),
+            new ButtonBuilder()
+                .setCustomId("message")
+                .setLabel((data.message ? "Change" : "Set") + "Message")
+                .setStyle(ButtonStyle.Primary)
+                .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
+            new ButtonBuilder()
+                .setCustomId("channelDM")
+                .setLabel("Send in DMs")
+                .setStyle(ButtonStyle.Primary)
+                .setDisabled(data.channel === "dm"),
+            new ButtonBuilder()
+                .setCustomId("role")
+                .setLabel("Clear Role")
+                .setStyle(ButtonStyle.Danger)
+                .setEmoji(getEmojiByName("CONTROL.CROSS", "id") as APIMessageComponentEmoji),
+            new ButtonBuilder()
+                .setCustomId("save")
+                .setLabel("Save")
+                .setStyle(ButtonStyle.Success)
+                .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+                .setDisabled(
+                    data.enabled === config.welcome.enabled &&
                         data.message === config.welcome.message &&
                         data.role === config.welcome.role &&
                         data.ping === config.welcome.ping &&
                         data.channel === config.welcome.channel
-                    )
-            );
+                )
+        );
 
-        const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>()
-            .addComponents(
-                new ChannelSelectMenuBuilder()
-                    .setCustomId("channel")
-                    .setPlaceholder("Select a channel to send welcome messages to")
-            );
-        const roleMenu = new ActionRowBuilder<RoleSelectMenuBuilder>()
-            .addComponents(
-                new RoleSelectMenuBuilder()
-                    .setCustomId("roleToGive")
-                    .setPlaceholder("Select a role to give to the member when they join the server")
-            );
-        const pingMenu = new ActionRowBuilder<RoleSelectMenuBuilder>()
-            .addComponents(
-                new RoleSelectMenuBuilder()
-                    .setCustomId("roleToPing")
-                    .setPlaceholder("Select a role to ping when a member joins the server")
-            );
+        const channelMenu = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
+            new ChannelSelectMenuBuilder()
+                .setCustomId("channel")
+                .setPlaceholder("Select a channel to send welcome messages to")
+        );
+        const roleMenu = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+            new RoleSelectMenuBuilder()
+                .setCustomId("roleToGive")
+                .setPlaceholder("Select a role to give to the member when they join the server")
+        );
+        const pingMenu = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+            new RoleSelectMenuBuilder()
+                .setCustomId("roleToPing")
+                .setPlaceholder("Select a role to ping when a member joins the server")
+        );
 
         const embed = new EmojiEmbed()
             .setTitle("Welcome Settings")
             .setStatus("Success")
             .setDescription(
-                `${getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS")} Welcome messages and roles are ${data.enabled ? "enabled" : "disabled"}\n` +
-                `**Welcome message:** ${data.message ?
-                    `\n> ` +
-                    await convertCurlyBracketString(
-                        data.message,
-                        interaction.user.id,
-                        interaction.user.username,
-                        interaction.guild!.name,
-                        interaction.guild!.members
-                    )
-                    : "*None*"}\n` +
-                `**Send message in:** ` + (data.channel ? (data.channel == "dm" ? "DMs" : renderChannel(data.channel)) : `*None set*`) + `\n` +
-                `**Role to ping:** ` + (data.ping ? `<@&${data.ping}>` : `*None set*`) + `\n` +
-                `**Role given on join:** ` + (data.role ? `<@&${data.role}>` : `*None set*`)
-            )
+                `${getEmojiByName(data.enabled ? "CONTROL.TICK" : "CONTROL.CROSS")} Welcome messages and roles are ${
+                    data.enabled ? "enabled" : "disabled"
+                }\n` +
+                    `**Welcome message:** ${
+                        data.message
+                            ? `\n> ` +
+                              (await convertCurlyBracketString(
+                                  data.message,
+                                  interaction.user.id,
+                                  interaction.user.username,
+                                  interaction.guild!.name,
+                                  interaction.guild!.members
+                              ))
+                            : "*None*"
+                    }\n` +
+                    `**Send message in:** ` +
+                    (data.channel ? (data.channel == "dm" ? "DMs" : renderChannel(data.channel)) : `*None set*`) +
+                    `\n` +
+                    `**Role to ping:** ` +
+                    (data.ping ? `<@&${data.ping}>` : `*None set*`) +
+                    `\n` +
+                    `**Role given on join:** ` +
+                    (data.role ? `<@&${data.role}>` : `*None set*`)
+            );
 
         await interaction.editReply({
             embeds: [embed],
@@ -121,17 +126,17 @@
 
         let i: RoleSelectMenuInteraction | ChannelSelectMenuInteraction | ButtonInteraction;
         try {
-            i = await m.awaitMessageComponent({
+            i = (await m.awaitMessageComponent({
                 filter: (interaction) => interaction.user.id === interaction.user.id,
                 time: 300000
-            }) as RoleSelectMenuInteraction | ChannelSelectMenuInteraction | ButtonInteraction;
+            })) as RoleSelectMenuInteraction | ChannelSelectMenuInteraction | ButtonInteraction;
         } catch (e) {
             closed = true;
             continue;
         }
 
-        if(i.isButton()) {
-            switch(i.customId) {
+        if (i.isButton()) {
+            switch (i.customId) {
                 case "switch": {
                     await i.deferUpdate();
                     data.enabled = !data.enabled;
@@ -148,7 +153,7 @@
                                     .setLabel("Server Info (1/3)")
                                     .setPlaceholder(
                                         `{serverName} - This server's name\n\n` +
-                                        `These placeholders will be replaced with the server's name, etc..`
+                                            `These placeholders will be replaced with the server's name, etc..`
                                     )
                                     .setMaxLength(1)
                                     .setRequired(false)
@@ -160,8 +165,8 @@
                                     .setLabel("Member Counts (2/3) - {MemberCount:...}")
                                     .setPlaceholder(
                                         `{:all} - Total member count\n` +
-                                        `{:humans} - Total non-bot users\n` +
-                                        `{:bots} - Number of bots\n`
+                                            `{:humans} - Total non-bot users\n` +
+                                            `{:bots} - Number of bots\n`
                                     )
                                     .setMaxLength(1)
                                     .setRequired(false)
@@ -171,32 +176,28 @@
                                 new TextInputBuilder()
                                     .setCustomId("ex3")
                                     .setLabel("Member who joined (3/3) - {member:...}")
-                                    .setPlaceholder(
-                                            `{:name} - The members name\n`
-                                    )
+                                    .setPlaceholder(`{:name} - The members name\n`)
                                     .setMaxLength(1)
                                     .setRequired(false)
                                     .setStyle(TextInputStyle.Paragraph)
                             ),
-                            new ActionRowBuilder<TextInputBuilder>()
-                                .addComponents(
-                                    new TextInputBuilder()
-                                        .setCustomId("message")
-                                        .setPlaceholder("Enter a message to send when someone joins the server")
-                                        .setValue(data.message ?? "")
-                                        .setLabel("Message")
-                                        .setStyle(TextInputStyle.Paragraph)
-                                )
-                        )
-                    const button = new ActionRowBuilder<ButtonBuilder>()
-                        .addComponents(
-                            new ButtonBuilder()
-                                .setCustomId("back")
-                                .setLabel("Back")
-                                .setStyle(ButtonStyle.Secondary)
-                                .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
-                        )
-                    await i.showModal(modal)
+                            new ActionRowBuilder<TextInputBuilder>().addComponents(
+                                new TextInputBuilder()
+                                    .setCustomId("message")
+                                    .setPlaceholder("Enter a message to send when someone joins the server")
+                                    .setValue(data.message ?? "")
+                                    .setLabel("Message")
+                                    .setStyle(TextInputStyle.Paragraph)
+                            )
+                        );
+                    const button = new ActionRowBuilder<ButtonBuilder>().addComponents(
+                        new ButtonBuilder()
+                            .setCustomId("back")
+                            .setLabel("Back")
+                            .setStyle(ButtonStyle.Secondary)
+                            .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+                    );
+                    await i.showModal(modal);
                     await i.editReply({
                         embeds: [
                             new EmojiEmbed()
@@ -209,21 +210,21 @@
 
                     let out: ModalSubmitInteraction | null;
                     try {
-                        out = await modalInteractionCollector(m, interaction.user) as ModalSubmitInteraction | null;
+                        out = (await modalInteractionCollector(m, interaction.user)) as ModalSubmitInteraction | null;
                     } catch (e) {
                         console.error(e);
                         out = null;
                     }
-                    if(!out) break;
+                    if (!out) break;
                     data.message = out.fields.getTextInputValue("message");
                     break;
                 }
                 case "save": {
                     await i.deferUpdate();
-                    await client.database.guilds.write(interaction.guild!.id, {"welcome": data});
+                    await client.database.guilds.write(interaction.guild!.id, { welcome: data });
                     config = await client.database.guilds.read(interaction.guild!.id);
                     data = Object.assign({}, config.welcome);
-                    await client.memory.forceUpdate(interaction.guild!.id)
+                    await client.memory.forceUpdate(interaction.guild!.id);
                     break;
                 }
                 case "channelDM": {
@@ -239,23 +240,22 @@
             }
         } else if (i.isRoleSelectMenu()) {
             await i.deferUpdate();
-            switch(i.customId) {
+            switch (i.customId) {
                 case "roleToGive": {
                     data.role = i.values[0]!;
-                    break
+                    break;
                 }
                 case "roleToPing": {
                     data.ping = i.values[0]!;
-                    break
+                    break;
                 }
             }
         } else {
             await i.deferUpdate();
             data.channel = i.values[0]!;
         }
-
     } while (!closed);
-    await interaction.deleteReply()
+    await interaction.deleteReply();
 };
 
 const check = (interaction: CommandInteraction, _partial: boolean = false) => {
@@ -266,16 +266,16 @@
 };
 
 const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
-    const validReplacements = ["serverName", "memberCount:all", "memberCount:bots", "memberCount:humans"]
+    const validReplacements = ["serverName", "memberCount:all", "memberCount:bots", "memberCount:humans"];
     if (!interaction.guild) return [];
     const prompt = interaction.options.getString("message");
     const autocompletions = [];
-    if ( prompt === null ) {
+    if (prompt === null) {
         for (const replacement of validReplacements) {
             autocompletions.push(`{${replacement}}`);
-        };
+        }
         return autocompletions;
-    };
+    }
     const beforeLastOpenBracket = prompt.match(/(.*){[^{}]{0,15}$/);
     const afterLastOpenBracket = prompt.match(/{[^{}]{0,15}$/);
     if (beforeLastOpenBracket !== null) {
