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;
 };
 
