diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index b430191..dc44e5a 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,11 +1,5 @@
 import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
-import Discord, {
-    CommandInteraction,
-    GuildMember,
-    Message,
-    MessageActionRow,
-    MessageButton
-} from "discord.js";
+import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -13,29 +7,17 @@
 import keyValueList from "../../utils/generateKeyValueList.js";
 import humanizeDuration from "humanize-duration";
 import client from "../../utils/client.js";
-import {
-    areTicketsEnabled,
-    create
-} from "../../actions/createModActionTicket.js";
+import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
         .setName("mute")
-        .setDescription(
-            "Mutes a member, stopping them from talking in the server"
-        )
-        .addUserOption((option) =>
-            option
-                .setName("user")
-                .setDescription("The user to mute")
-                .setRequired(true)
-        )
+        .setDescription("Mutes a member, stopping them from talking in the server")
+        .addUserOption((option) => option.setName("user").setDescription("The user to mute").setRequired(true))
         .addIntegerOption((option) =>
             option
                 .setName("days")
-                .setDescription(
-                    "The number of days to mute the user for | Default: 0"
-                )
+                .setDescription("The number of days to mute the user for | Default: 0")
                 .setMinValue(0)
                 .setMaxValue(27)
                 .setRequired(false)
@@ -43,9 +25,7 @@
         .addIntegerOption((option) =>
             option
                 .setName("hours")
-                .setDescription(
-                    "The number of hours to mute the user for | Default: 0"
-                )
+                .setDescription("The number of hours to mute the user for | Default: 0")
                 .setMinValue(0)
                 .setMaxValue(23)
                 .setRequired(false)
@@ -53,9 +33,7 @@
         .addIntegerOption((option) =>
             option
                 .setName("minutes")
-                .setDescription(
-                    "The number of minutes to mute the user for | Default: 0"
-                )
+                .setDescription("The number of minutes to mute the user for | Default: 0")
                 .setMinValue(0)
                 .setMaxValue(59)
                 .setRequired(false)
@@ -63,17 +41,14 @@
         .addIntegerOption((option) =>
             option
                 .setName("seconds")
-                .setDescription(
-                    "The number of seconds to mute the user for | Default: 0"
-                )
+                .setDescription("The number of seconds to mute the user for | Default: 0")
                 .setMinValue(0)
                 .setMaxValue(59)
                 .setRequired(false)
         );
 
 const callback = async (interaction: CommandInteraction): Promise<unknown> => {
-    const { log, NucleusColors, renderUser, entry, renderDelta } =
-        client.logger;
+    const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
     const user = interaction.options.getMember("user") as GuildMember;
     const time = {
         days: interaction.options.getInteger("days") ?? 0,
@@ -82,19 +57,12 @@
         seconds: interaction.options.getInteger("seconds") ?? 0
     };
     const config = await client.database.guilds.read(interaction.guild.id);
-    let serverSettingsDescription = config.moderation.mute.timeout
-        ? "given a timeout"
-        : "";
+    let serverSettingsDescription = config.moderation.mute.timeout ? "given a timeout" : "";
     if (config.moderation.mute.role)
         serverSettingsDescription +=
-            (serverSettingsDescription ? " and " : "") +
-            `given the <@&${config.moderation.mute.role}> role`;
+            (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`;
 
-    let muteTime =
-        time.days * 24 * 60 * 60 +
-        time.hours * 60 * 60 +
-        time.minutes * 60 +
-        time.seconds;
+    let muteTime = time.days * 24 * 60 * 60 + time.hours * 60 * 60 + time.minutes * 60 + time.seconds;
     if (muteTime === 0) {
         const m = (await interaction.reply({
             embeds: [
@@ -106,40 +74,16 @@
             ],
             components: [
                 new MessageActionRow().addComponents([
-                    new Discord.MessageButton()
-                        .setCustomId("1m")
-                        .setLabel("1 Minute")
-                        .setStyle("SECONDARY"),
-                    new Discord.MessageButton()
-                        .setCustomId("10m")
-                        .setLabel("10 Minutes")
-                        .setStyle("SECONDARY"),
-                    new Discord.MessageButton()
-                        .setCustomId("30m")
-                        .setLabel("30 Minutes")
-                        .setStyle("SECONDARY"),
-                    new Discord.MessageButton()
-                        .setCustomId("1h")
-                        .setLabel("1 Hour")
-                        .setStyle("SECONDARY")
+                    new Discord.MessageButton().setCustomId("1m").setLabel("1 Minute").setStyle("SECONDARY"),
+                    new Discord.MessageButton().setCustomId("10m").setLabel("10 Minutes").setStyle("SECONDARY"),
+                    new Discord.MessageButton().setCustomId("30m").setLabel("30 Minutes").setStyle("SECONDARY"),
+                    new Discord.MessageButton().setCustomId("1h").setLabel("1 Hour").setStyle("SECONDARY")
                 ]),
                 new MessageActionRow().addComponents([
-                    new Discord.MessageButton()
-                        .setCustomId("6h")
-                        .setLabel("6 Hours")
-                        .setStyle("SECONDARY"),
-                    new Discord.MessageButton()
-                        .setCustomId("12h")
-                        .setLabel("12 Hours")
-                        .setStyle("SECONDARY"),
-                    new Discord.MessageButton()
-                        .setCustomId("1d")
-                        .setLabel("1 Day")
-                        .setStyle("SECONDARY"),
-                    new Discord.MessageButton()
-                        .setCustomId("1w")
-                        .setLabel("1 Week")
-                        .setStyle("SECONDARY")
+                    new Discord.MessageButton().setCustomId("6h").setLabel("6 Hours").setStyle("SECONDARY"),
+                    new Discord.MessageButton().setCustomId("12h").setLabel("12 Hours").setStyle("SECONDARY"),
+                    new Discord.MessageButton().setCustomId("1d").setLabel("1 Day").setStyle("SECONDARY"),
+                    new Discord.MessageButton().setCustomId("1w").setLabel("1 Week").setStyle("SECONDARY")
                 ]),
                 new MessageActionRow().addComponents([
                     new Discord.MessageButton()
@@ -228,9 +172,7 @@
                     time: `${humanizeDuration(muteTime * 1000, {
                         round: true
                     })}`,
-                    reason: reason
-                        ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
-                        : "*No reason provided*"
+                    reason: reason ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ") : "*No reason provided*"
                 }) +
                     "The user will be " +
                     serverSettingsDescription +
@@ -244,12 +186,7 @@
                 "Create appeal ticket",
                 !(await areTicketsEnabled(interaction.guild.id)),
                 async () =>
-                    await create(
-                        interaction.guild,
-                        interaction.options.getUser("user"),
-                        interaction.user,
-                        reason
-                    ),
+                    await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
                 "An appeal ticket will be created when Confirm is clicked",
                 "CONTROL.TICKET",
                 createAppealTicket
@@ -291,17 +228,9 @@
                                         ? ` for:\n> ${reason}`
                                         : ".\n\n" +
                                           `You will be unmuted at: <t:${
-                                              Math.round(
-                                                  new Date().getTime() / 1000
-                                              ) + muteTime
-                                          }:D> at <t:${
-                                              Math.round(
-                                                  new Date().getTime() / 1000
-                                              ) + muteTime
-                                          }:T> (<t:${
-                                              Math.round(
-                                                  new Date().getTime() / 1000
-                                              ) + muteTime
+                                              Math.round(new Date().getTime() / 1000) + muteTime
+                                          }:D> at <t:${Math.round(new Date().getTime() / 1000) + muteTime}:T> (<t:${
+                                              Math.round(new Date().getTime() / 1000) + muteTime
                                           }:R>)`) +
                                     (confirmation.components.appeal.response
                                         ? `You can appeal this here: <#${confirmation.components.appeal.response}>`
@@ -331,10 +260,7 @@
         let errors = 0;
         try {
             if (config.moderation.mute.timeout) {
-                await member.timeout(
-                    muteTime * 1000,
-                    reason || "No reason provided"
-                );
+                await member.timeout(muteTime * 1000, reason || "No reason provided");
                 if (config.moderation.mute.role !== null) {
                     await member.roles.add(config.moderation.mute.role);
                     await client.database.eventScheduler.schedule(
@@ -354,15 +280,11 @@
         try {
             if (config.moderation.mute.role !== null) {
                 await member.roles.add(config.moderation.mute.role);
-                await client.database.eventScheduler.schedule(
-                    "unmuteRole",
-                    new Date().getTime() + muteTime * 1000,
-                    {
-                        guild: interaction.guild.id,
-                        user: user.id,
-                        role: config.moderation.mute.role
-                    }
-                );
+                await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
+                    guild: interaction.guild.id,
+                    user: user.id,
+                    role: config.moderation.mute.role
+                });
             }
         } catch (e) {
             console.log(e);
@@ -374,9 +296,7 @@
                     new EmojiEmbed()
                         .setEmoji("PUNISH.MUTE.RED")
                         .setTitle("Mute")
-                        .setDescription(
-                            "Something went wrong and the user was not muted"
-                        )
+                        .setDescription("Something went wrong and the user was not muted")
                         .setStatus("Danger")
                 ],
                 components: []
@@ -384,13 +304,7 @@
             if (dmd) await dm.delete();
             return;
         }
-        await client.database.history.create(
-            "mute",
-            interaction.guild.id,
-            member.user,
-            interaction.user,
-            reason
-        );
+        await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
         const failed = !dmd && notify;
         await interaction.editReply({
             embeds: [
@@ -424,14 +338,8 @@
                     new Date().getTime() + muteTime * 1000,
                     renderDelta(new Date().getTime() + muteTime * 1000)
                 ),
-                muted: entry(
-                    new Date().getTime(),
-                    renderDelta(new Date().getTime() - 1000)
-                ),
-                mutedBy: entry(
-                    interaction.member.user.id,
-                    renderUser(interaction.member.user)
-                ),
+                muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)),
+                mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
                 reason: entry(reason, reason ? reason : "*No reason provided*")
             },
             hidden: {
@@ -457,30 +365,24 @@
     const member = interaction.member as GuildMember;
     const me = interaction.guild.me!;
     const apply = interaction.options.getMember("user") as GuildMember;
-    if (member === null || me === null || apply === null)
-        throw "That member is not in the server";
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
     const memberPos = member.roles ? member.roles.highest.position : 0;
     const mePos = me.roles ? me.roles.highest.position : 0;
     const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow muting the owner
-    if (member.id === interaction.guild.ownerId)
-        throw "You cannot mute the owner of the server";
+    if (member.id === interaction.guild.ownerId) throw "You cannot mute the owner of the server";
     // Check if Nucleus can mute the member
-    if (!(mePos > applyPos))
-        throw "I do not have a role higher than that member";
+    if (!(mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to mute
-    if (!me.permissions.has("MODERATE_MEMBERS"))
-        throw "I do not have the *Moderate Members* permission";
+    if (!me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
     // Do not allow muting Nucleus
     if (member.id === me.id) throw "I cannot mute myself";
     // Allow the owner to mute anyone
     if (member.id === interaction.guild.ownerId) return true;
     // Check if the user has moderate_members permission
-    if (!member.permissions.has("MODERATE_MEMBERS"))
-        throw "You do not have the *Moderate Members* permission";
+    if (!member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
     // Check if the user is below on the role list
-    if (!(memberPos > applyPos))
-        throw "You do not have a role higher than that member";
+    if (!(memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow mute
     return true;
 };
