diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 05eb603..5c482f1 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -78,12 +79,7 @@
 }
 
 const callback = async (interaction: CommandInteraction) => {
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Role all")
-        .setDescription("Loading...")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true})
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
     let filters: Filter[] = [
         filterList.member.has.role("959901346000154674"),
         filterList.member.nickname.startsWith("Pinea"),
@@ -112,7 +108,7 @@
             .setDescription((all ? "All of the following must be true:" : "Any of the following must be true") + "\n" +
                 filters.map((f) => {
                     count ++;
-                    return (count == 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
+                    return (count === 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
                         (f.inverted ? "**not** " : "") + `${f.name}`
                 }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
             .setEmoji("GUILD.ROLES.CREATE")
@@ -144,11 +140,11 @@
 const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
-    if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the Manage roles permission";
+    if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the *Manage Roles* permission";
     // Allow the owner to role anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has manage_roles permission
-    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
     // Allow role
     return true;
 }
diff --git a/src/commands/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
similarity index 92%
rename from src/commands/categorisationTest.ts
rename to src/Unfinished/categorisationTest.ts
index b052783..c75d1bb 100644
--- a/src/commands/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,23 +1,20 @@
+import { LoadingEmbed } from '../utils/defaultEmbeds.js';
 import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
-import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
+import { SlashCommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import client from "../utils/client.js"
 import addPlural from "../utils/plurals.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-const command = new SlashCommandBuilder() // TODO: remove for release
+const command = new SlashCommandBuilder()
     .setName("categorise")
     .setDescription("Categorises your servers channels")
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
     let categorised = {}
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading...")
-        .setEmoji("NUCLEUS.LOADING")
-        .setStatus("Success")
-    ], ephemeral: true});
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
     let predicted = {}
     let types = {
         general: ["general", "muted", "main", "topic", "discuss"],
diff --git a/src/actions/createModActionTicket.ts b/src/actions/createModActionTicket.ts
index 40f99b9..72ba011 100644
--- a/src/actions/createModActionTicket.ts
+++ b/src/actions/createModActionTicket.ts
@@ -16,7 +16,7 @@
         deny: ["VIEW_CHANNEL"],
         type: "role"
     })
-    if (config.tickets.supportRole != null) {
+    if (config.tickets.supportRole !== null) {
         overwrites.push({
             id: guild.roles.cache.get(config.tickets.supportRole),
             allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
@@ -40,10 +40,10 @@
     try {
         await c.send(
             {
-                content: (`<@${member.id}>` + (config.tickets.supportRole != null ? ` • <@&${config.tickets.supportRole}>` : "")),
+                content: (`<@${member.id}>` + (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : "")),
                 allowedMentions: {
                     users: [member.id],
-                    roles: (config.tickets.supportRole != null ? [config.tickets.supportRole] : [])
+                    roles: (config.tickets.supportRole !== null ? [config.tickets.supportRole] : [])
                 }
             }
         )
@@ -51,7 +51,7 @@
             .setTitle("New Ticket")
             .setDescription(
                 `Ticket created by a Moderator\n` +
-                `**Support type:** Appeal submission\n` + (reason != null ? `**Reason:**\n> ${reason}\n` : "") +
+                `**Support type:** Appeal submission\n` + (reason !== null ? `**Reason:**\n> ${reason}\n` : "") +
                 `**Ticket ID:** \`${c.id}\`\n` +
                 `Type \`/ticket close\` to close this ticket.`,
             )
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index a4397a3..7432a3a 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -3,6 +3,7 @@
 import { MessageActionRow, MessageSelectMenu } from 'discord.js';
 import getEmojiByName from "../utils/getEmojiByName.js";
 import client from "../utils/client.js";
+import { LoadingEmbed } from "../utils/defaultEmbeds.js";
 
 export async function callback(interaction) {
     let config = await client.database.guilds.read(interaction.guild.id);
@@ -18,12 +19,7 @@
         .setStatus("Danger")
         .setEmoji("CONTROL.BLOCKCROSS")
     ], ephemeral: true})
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Roles")
-        .setDescription("Loading...")
-        .setStatus("Success")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true})
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
     let m;
     if (config.roleMenu.allowWebUI) {
         let code = ""
@@ -54,7 +50,7 @@
         let up = true
         try {
             let status = await fetch(client.config.baseUrl).then(res => res.status);
-            if (status != 200) up = false
+            if (status !== 200) up = false
         } catch { up = false }
         m = await interaction.editReply({
             embeds: [new EmojiEmbed()
@@ -88,7 +84,7 @@
                     .setTitle("Roles")
                     .setEmoji("GUILD.GREEN")
                     .setDescription(`**${object.name}**` + (object.description ? `\n${object.description}` : ``) +
-                        `\n\nSelect ${object.min}` + (object.min != object.max ? ` to ${object.max}` : ``) + ` role${object.max == 1 ? '' : 's'} to add.`)
+                        `\n\nSelect ${object.min}` + (object.min !== object.max ? ` to ${object.max}` : ``) + ` role${object.max === 1 ? '' : 's'} to add.`)
                     .setStatus("Success")
                     .setFooter({text: `Step ${i + 1}/${config.roleMenu.options.length}`})
             ],
@@ -99,7 +95,7 @@
                         .setStyle("DANGER")
                         .setCustomId("cancel")
                         .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    ].concat(object.min == 0 ? [
+                    ].concat(object.min === 0 ? [
                         new MessageButton()
                             .setLabel("Skip")
                             .setStyle("SECONDARY")
@@ -121,9 +117,9 @@
             return
         }
         component.deferUpdate()
-        if (component.customId == "rolemenu") {
+        if (component.customId === "rolemenu") {
             rolesToAdd = rolesToAdd.concat(component.values)
-        } else if (component.customId == "cancel") {
+        } else if (component.customId === "cancel") {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Roles")
                 .setDescription("Cancelled. No changes were made.")
diff --git a/src/actions/tickets/create.ts b/src/actions/tickets/create.ts
index e21aa3e..722eb3f 100644
--- a/src/actions/tickets/create.ts
+++ b/src/actions/tickets/create.ts
@@ -24,7 +24,7 @@
     let category = interaction.guild.channels.cache.get(config.tickets.category) as Discord.CategoryChannel;
     let count = 0;
     category.children.forEach(element => {
-        if (!(element.type == "GUILD_TEXT")) return;
+        if (!(element.type === "GUILD_TEXT")) return;
         if ((element as Discord.TextChannel).topic.includes(`${interaction.member.user.id}`)) {
             if ((element as Discord.TextChannel).topic.endsWith("Active")) {
                 count++;
@@ -84,13 +84,13 @@
             if (custom) {
                 return new MessageButton()
                     .setLabel(type)
-                    .setStyle(chosenType == type ? "SUCCESS" : "SECONDARY")
+                    .setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
                     .setCustomId(type)
                     .setDisabled(true)
                 } else {
                     return new MessageButton()
                     .setLabel(capitalize(type))
-                    .setStyle(chosenType == type ? "SUCCESS" : "SECONDARY")
+                    .setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
                     .setCustomId(type)
                     .setEmoji(getEmojiByName(("TICKETS." + type.toString().toUpperCase()), "id"))
                     .setDisabled(true)
@@ -122,7 +122,7 @@
         deny: ["VIEW_CHANNEL"],
         type: "role"
     })
-    if (config.tickets.supportRole != null) {
+    if (config.tickets.supportRole !== null) {
         overwrites.push({
             id: interaction.guild.roles.cache.get(config.tickets.supportRole),
             allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
@@ -151,10 +151,10 @@
     try {
         await c.send(
             {
-                content: (`<@${interaction.member.user.id}>` + (config.tickets.supportRole != null ? ` • <@&${config.tickets.supportRole}>` : "")),
+                content: (`<@${interaction.member.user.id}>` + (config.tickets.supportRole !== null ? ` • <@&${config.tickets.supportRole}>` : "")),
                 allowedMentions: {
                     users: [(interaction.member as Discord.GuildMember).id],
-                    roles: (config.tickets.supportRole != null ? [config.tickets.supportRole] : [])
+                    roles: (config.tickets.supportRole !== null ? [config.tickets.supportRole] : [])
                 }
             }
         )
@@ -165,7 +165,7 @@
             .setTitle("New Ticket")
             .setDescription(
                 `Ticket created by <@${interaction.member.user.id}>\n` +
-                `**Support type:** ${chosenType != null ? (emoji) + " " + capitalize(chosenType) : "General"}\n` +
+                `**Support type:** ${chosenType !== null ? (emoji) + " " + capitalize(chosenType) : "General"}\n` +
                 `**Ticket ID:** \`${c.id}\`\n${content}\n` +
                 `Type \`/ticket close\` to close this ticket.`,
             )
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index c14cf0c..d86396a 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -10,7 +10,7 @@
     let thread = false; let threadChannel
     if (interaction.channel instanceof Discord.ThreadChannel) thread = true; threadChannel = interaction.channel as Discord.ThreadChannel
     let channel = (interaction.channel as Discord.TextChannel)
-    if (!channel.parent || config.tickets.category != channel.parent.id || (thread ? (threadChannel.parent.parent.id != config.tickets.category) : false)) {
+    if (!channel.parent || config.tickets.category !== channel.parent.id || (thread ? (threadChannel.parent.parent.id !== config.tickets.category) : false)) {
         return interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Deleting Ticket...")
             .setDescription("This ticket is not in your tickets category, so cannot be deleted. You cannot run close in a thread.")
@@ -19,7 +19,7 @@
         ], ephemeral: true});
     }
     let status = channel.topic.split(" ")[1];
-    if (status == "Archived") {
+    if (status === "Archived") {
         await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Delete Ticket")
             .setDescription("Your ticket is being deleted...")
@@ -47,7 +47,7 @@
         log(data);
         interaction.channel.delete();
         return;
-    } else if (status == "Active") {
+    } else if (status === "Active") {
         await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Close Ticket")
             .setDescription("Your ticket is being closed...")
@@ -66,7 +66,7 @@
                 type: "role"
             }
         ] as Discord.OverwriteResolvable[];
-        if (config.tickets.supportRole != null) {
+        if (config.tickets.supportRole !== null) {
             overwrites.push({
                 id: interaction.guild.roles.cache.get(config.tickets.supportRole),
                 allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
@@ -127,8 +127,8 @@
     let ticketChannels = tickets.children;
     let deleted = 0
     ticketChannels.forEach(element => {
-        if (element.type != "GUILD_TEXT") return;
-        if (element.topic.split(" ")[0] == member) {
+        if (element.type !== "GUILD_TEXT") return;
+        if (element.topic.split(" ")[0] === member) {
             try { element.delete(); } catch {}
             deleted++
         }
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 2068b15..5da8693 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -104,7 +104,7 @@
             if (dmd) await dm.delete()
             return
         }
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
             .setTitle(`Ban`)
@@ -125,20 +125,20 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Check if Nucleus can ban the member
     if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
     // Check if Nucleus has permission to ban
-    if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
+    if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
     // Do not allow banning Nucleus
-    if (member.id == interaction.guild.me.id) throw "I cannot ban myself"
+    if (member.id === interaction.guild.me.id) throw "I cannot ban myself"
     // Allow the owner to ban anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has ban_members permission
-    if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
+    if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban 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"
     // Allow ban
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 0ea93d8..c50c6f4 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -143,7 +143,7 @@
         let end = "\n\nJanuary " + currentYear.toString() + pageIndicator(
             Math.max(groups.length, 1),
             groups.length === 0 ? 1 : pageIndex
-        ) + (currentYear == new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
+        ) + (currentYear === new Date().getFullYear() ? monthNames[new Date().getMonth()] : "December"
         ) + " " + currentYear.toString()
         if (groups.length > 0) {
             let toRender = groups[Math.min(pageIndex, groups.length - 1)]
@@ -204,8 +204,8 @@
     let member = (interaction.options.getMember("user")) as Discord.GuildMember;
     await interaction.reply({embeds: [new EmojiEmbed()
         .setEmoji("NUCLEUS.LOADING")
-        .setTitle("Downloading data...")
-        .setStatus("Success")
+        .setTitle("Downloading Data")
+        .setStatus("Danger")
     ], ephemeral: true, fetchReply: true});
     let note;
     let firstLoad = true;
@@ -260,7 +260,7 @@
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => m.customId == "modify")
+                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
             } catch (e) { continue }
             if (out.fields) {
                 let toAdd = out.fields.getTextInputValue("note") || null;
@@ -275,7 +275,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as GuildMember)
-    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";
     return true
 }
 
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index eac7ca3..a0b9a97 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -103,7 +103,7 @@
             if (dmd) await dm.delete()
             return
         }
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
             .setTitle(`Kick`)
@@ -124,20 +124,20 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Check if Nucleus can kick the member
     if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
     // Check if Nucleus has permission to kick
-    if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the Kick members permission";
+    if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the *Kick Members* permission";
     // Do not allow kicking Nucleus
-    if (member.id == interaction.guild.me.id) throw "I cannot kick myself"
+    if (member.id === interaction.guild.me.id) throw "I cannot kick myself"
     // Allow the owner to kick anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has kick_members permission
-    if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the Kick members permission";
+    if (! member.permissions.has("KICK_MEMBERS")) throw "You do not have the *Kick 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"
     // Allow kick
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index f98bd6a..8bb6854 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -33,7 +34,7 @@
     if (config.moderation.mute.role) serverSettingsDescription += (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
-    if (muteTime == 0) {
+    if (muteTime === 0) {
         let m = await interaction.reply({embeds: [
             new EmojiEmbed()
                 .setEmoji("PUNISH.MUTE.GREEN")
@@ -90,7 +91,7 @@
             component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
         } catch { return }
         component.deferUpdate();
-        if (component.customId == "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
+        if (component.customId === "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.MUTE.RED")
             .setTitle("Mute")
             .setDescription("Mute cancelled")
@@ -107,13 +108,7 @@
             case "1w": { muteTime = 60 * 60 * 24 * 7; break; }
         }
     } else {
-        await interaction.reply({embeds: [
-            new EmojiEmbed()
-                .setEmoji("PUNISH.MUTE.GREEN")
-                .setTitle("Mute")
-                .setDescription("Loading...")
-                .setStatus("Success")
-        ], ephemeral: true, fetchReply: true})
+        await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
     }
     // TODO:[Modals] Replace this with a modal
     let reason = null;
@@ -199,7 +194,7 @@
                 })
             }
         } catch (e){ console.log(e); errors++ }
-        if (errors == 2) {
+        if (errors === 2) {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.MUTE.RED")
                 .setTitle(`Mute`)
@@ -210,7 +205,7 @@
             return
         }
         try { await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason) } catch {}
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
             .setTitle(`Mute`)
@@ -253,22 +248,22 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Check if Nucleus can mute the 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 the user to have admin or be the owner
-    if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
+    if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id === interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
     // Do not allow muting Nucleus
-    if (member.id == me.id) throw "I cannot mute myself"
+    if (member.id === me.id) throw "I cannot mute myself"
     // Allow the owner to mute anyone
-    if (member.id == interaction.guild.ownerId) return true
+    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"
     // Allow mute
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 3ff18ec..cf33109 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -96,7 +96,7 @@
             if (dmd) await dm.delete()
             return
         }
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
             .setTitle(`Nickname`)
@@ -117,20 +117,20 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Check if Nucleus can change the nickname
     if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
     // Check if Nucleus has permission to change the nickname
-    if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the Manage nicknames permission";
+    if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the *Manage Nicknames* permission";
     // Allow the owner to change anyone's nickname
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has manage_nicknames permission
-    if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the Manage nicknames permission";
+    if (! member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the *Manage Nicknames* permission";
     // Allow changing your own nickname
-    if (member == apply) return true
+    if (member === apply) return true
     // Check if the user is below on the role list
     if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
     // Allow change
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index af7beb3..e1e4de9 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -314,11 +314,11 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     // Allow the owner to purge
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has manage_messages permission
-    if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the Manage messages permission";
+    if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the *Manage Messages* permission";
     // Check if nucleus has the manage_messages permission
-    if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the Manage messages permission";
+    if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
     // Allow warn
     return true
 }
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 2b386fd..6b33e12 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -62,9 +62,9 @@
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as GuildMember)
     // Check if Nucleus can set the slowmode
-    if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the Manage channels permission";
+    if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the *Manage Channels* permission";
     // Check if the user has manage_channel permission
-    if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the Manage channels permission";
+    if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the *Manage Channels* permission";
     // Allow slowmode
     return true
 }
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 7fefb1b..5c7e8c4 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -81,7 +81,7 @@
             ], components: []})
         }
         try { await client.database.history.create("softban", interaction.guild.id, member.user, reason) } catch {}
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
             .setTitle(`Softban`)
@@ -102,20 +102,20 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Check if Nucleus can ban the member
     if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
     // Check if Nucleus has permission to ban
-    if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
+    if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
     // Do not allow softbanning Nucleus
-    if (member.id == me.id) throw "I cannot softban myself"
+    if (member.id === me.id) throw "I cannot softban myself"
     // Allow the owner to ban anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has ban_members permission
-    if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
+    if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban 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"
     // Allow softban
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 035b809..2605d28 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -15,9 +15,9 @@
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let bans = await interaction.guild.bans.fetch()
     let user = interaction.options.getString("user")
-    let resolved = bans.find(ban => ban.user.id == user)
-    if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() == user.toLowerCase())
-    if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() == user.toLowerCase())
+    let resolved = bans.find(ban => ban.user.id === user)
+    if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() === user.toLowerCase())
+    if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() === user.toLowerCase())
     if (!resolved) {
         return interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Unban")
@@ -92,11 +92,11 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     // Check if Nucleus can unban members
-    if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the Ban members permission";
+    if (! me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
     // Allow the owner to unban anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has ban_members permission
-    if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the Ban members permission";
+    if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
     // Allow unban
     return true
 }
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 56a0b56..25aacfa 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -89,7 +89,7 @@
             }
         }
         log(data);
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
             .setTitle(`Unmute`)
@@ -110,20 +110,20 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Check if Nucleus can unmute the member
     if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
     // Check if Nucleus has permission to unmute
-    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 the user to have admin or be the owner
-    if (apply.permissions.has("ADMINISTRATOR") || apply.id == interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
+    if (apply.permissions.has("ADMINISTRATOR") || apply.id === interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
     // Allow the owner to unmute anyone
-    if (member.id == interaction.guild.ownerId) return true
+    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"
     // Allow unmute
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index 684fc3a..2f5cacc 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -51,7 +51,7 @@
                 `**${channels[page][0].parent ? channels[page][0].parent.name  : "Uncategorised"}**` + "\n" +
                 channels[page].map(c => {
                     let channelType = c.type
-                    if (interaction.guild.rulesChannelId == c.id) channelType = "RULES"
+                    if (interaction.guild.rulesChannelId === c.id) channelType = "RULES"
                     else if ("nsfw" in c && c.nsfw) channelType += "_NSFW"
                     return c.permissionsFor(member).has("VIEW_CHANNEL") ? (
                         `${getEmojiByName("ICONS.CHANNEL." + channelType)} ${c.name}\n` + (() => {
@@ -98,7 +98,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as GuildMember)
-    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
     return true
 }
 
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 3e76321..5a42911 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -98,7 +98,7 @@
             interaction.user, reason
         )} catch {}
         log(data);
-        let failed = (dmd == false && notify)
+        let failed = (dmd === false && notify)
         if (!failed) {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji(`PUNISH.WARN.GREEN`)
@@ -138,7 +138,7 @@
                     .setStatus("Success")
                 ], components: []})
             }
-            if ( component.customId == "here" ) {
+            if ( component.customId === "here" ) {
                 await interaction.channel.send({
                     embeds: [new EmojiEmbed()
                         .setEmoji(`PUNISH.WARN.RED`)
@@ -179,16 +179,16 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     let memberPos = member.roles ? member.roles.highest.position : 0
     let mePos = me.roles ? me.roles.highest.position : 0
     let applyPos = apply.roles ? apply.roles.highest.position : 0
     // Do not allow warning bots
     if (member.user.bot) throw "I cannot warn bots"
     // Allow the owner to warn anyone
-    if (member.id == interaction.guild.ownerId) return true
+    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"
     // Allow warn
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index f10dcae..6353843 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import { CommandInteraction } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -13,12 +14,7 @@
     // WEBSOCKET | Nucleus -> Discord
     // EDITING   | Nucleus -> discord -> nucleus | edit time / 2
     let initial = new Date().getTime();
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Ping")
-        .setDescription(`Checking ping times...`)
-        .setEmoji("NUCLEUS.LOADING")
-        .setStatus("Danger")
-    ], ephemeral: true});
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
     let ping = new Date().getTime() - initial;
     interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Ping")
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 6d62745..81d1503 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,35 +1,169 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import { SlashCommandBuilder } from "@discordjs/builders";
+import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import { testLink, testMalware, testNSFW } from "../reflex/scanners.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
+import getEmojiByName from "../utils/getEmojiByName.js";
+import createPageIndicator from "../utils/createPageIndicator.js";
+import client from "../utils/client.js";
+import confirmationMessage from "../utils/confirmationMessage.js";
 
 const command = new SlashCommandBuilder()
     .setName("privacy")
     .setDescription("Information and options for you and your server's settings")
 
+class Embed {
+    embed: Discord.MessageEmbed;
+    title: string;
+    description: string = "";
+    pageId: number = 0;
+    components?: MessageActionRow[] = [];
+    setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
+    setTitle(title: string) { this.title = title; return this; }
+    setDescription(description: string) { this.description = description; return this; }
+    setPageId(pageId: number) { this.pageId = pageId; return this; }
+    setComponents(components: MessageActionRow[]) { this.components = components; return this; }
+}
+
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let components = [];
-    if (interaction.inCachedGuild() && interaction.member.permissions.has("MANAGE_GUILD")) {
-        components.push(new MessageActionRow().addComponents([new MessageButton()
-            .setLabel("Clear all data")
-            .setEmoji("CONTROL.CROSS")
-            .setCustomId("clear")
-            .setStyle("DANGER")
-        ]));
+    let pages = [
+        new Embed()
+            .setEmbed(new EmojiEmbed()
+                .setTitle("Nucleus Privacy")
+                .setDescription(
+                    "Nucleus is a bot that naturally needs to store data about servers.\n" +
+                    "We are entirely [open source](https://github.com/ClicksMinutePer/Nucleus), so you can check exactly what we store, and how it works.\n\n" +
+                    "If you are a server administrator, you can view the options page in the dropdown under this message.\n\n" +
+                    "Any questions about Nucleus, how it works and data stored can be asked in [our server](https://discord.gg/bPaNnxe)."
+                )
+                .setEmoji("NUCLEUS.LOGO")
+                .setStatus("Danger")
+            ).setTitle("Welcome").setDescription("General privacy information").setPageId(0),
+        new Embed()
+            .setEmbed(new EmojiEmbed()
+                .setTitle("Scanners")
+                .setDescription(
+                    "Nucleus uses [unscan](https://unscan.co) to scan links, images and files for malware and other threats.\n" +
+                    "This service's [privacy policy](https://unscan.co/policies) is public, and they \"do not store or sell your data.\""
+                )
+                .setEmoji("NUCLEUS.LOGO")
+                .setStatus("Danger")
+            ).setTitle("Scanners").setDescription("About Unscan").setPageId(1),
+        new Embed()
+            .setEmbed(new EmojiEmbed()
+                .setTitle("Link scanning and Transcripts")
+                .setDescription(
+                    "**Facebook** - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
+                    "**AMP** - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
+                    "Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
+                )
+                .setEmoji("NUCLEUS.LOGO")
+                .setStatus("Danger")
+            ).setTitle("Link scanning and Transcripts").setDescription("Regarding Facebook and AMP filter types, and ticket transcripts").setPageId(2)
+    ].concat((interaction.member as Discord.GuildMember).permissions.has("ADMINISTRATOR") ? [new Embed()
+        .setEmbed(new EmojiEmbed()
+            .setTitle("Options")
+            .setDescription(
+                "Below are buttons for controlling this servers privacy settings"
+            )
+            .setEmoji("NUCLEUS.LOGO")
+            .setStatus("Danger")
+        ).setTitle("Options").setDescription("Options").setPageId(3).setComponents([new MessageActionRow().addComponents([
+            new MessageButton().setLabel("Clear all data").setCustomId("clear-all-data").setStyle("DANGER")
+        ])])
+    ] : []);
+    let m;
+    m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+    let page = 0;
+
+    let selectPaneOpen = false;
+    let nextFooter = null;
+
+    while (true) {
+        let selectPane = []
+
+        if (selectPaneOpen) {
+            let options = [];
+            pages.forEach(embed => {
+                options.push(new SelectMenuOption({
+                    label: embed.title,
+                    value: embed.pageId.toString(),
+                    description: embed.description || "",
+                }))
+            })
+            selectPane = [new MessageActionRow().addComponents([
+                new Discord.MessageSelectMenu()
+                    .addOptions(options)
+                    .setCustomId("page")
+                    .setMaxValues(1)
+                    .setPlaceholder("Choose a page...")
+            ])]
+        }
+        let components = selectPane.concat([new MessageActionRow().addComponents([
+            new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
+            new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
+            new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1)
+        ])])
+        let em = new Discord.MessageEmbed(pages[page].embed)
+        em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
+        em.setFooter({text: nextFooter ?? ""})
+        await interaction.editReply({
+            embeds: [em],
+            components: components.concat(pages[page].components)
+        });
+        let i
+        try {
+            i = await m.awaitMessageComponent({time: 300000});
+        } catch(e) { break }
+        nextFooter = null
+        i.deferUpdate()
+        if (i.component.customId === "left") {
+            if (page > 0) page--;
+            selectPaneOpen = false;
+        } else if (i.component.customId === "right") {
+            if (page < pages.length - 1) page++;
+            selectPaneOpen = false;
+        } else if (i.component.customId === "select") {
+            selectPaneOpen = !selectPaneOpen;
+        } else if (i.component.customId === "page") {
+            page = parseInt(i.values[0]);
+            selectPaneOpen = false;
+        } else if (i.component.customId === "clear-all-data") {
+            let confirmation = await new confirmationMessage(interaction)
+                .setEmoji("CONTROL.BLOCKCROSS")
+                .setTitle("Clear All Data")
+                .setDescription(
+                    `Are you sure you want to delete all data on this server? This includes your settings and all punishment histories.\n\n` +
+                    "**This cannot be undone.**"
+                )
+                .setColor("Danger")
+            .send(true)
+            if (confirmation.cancelled) { break; }
+            if (confirmation.success) {
+                client.database.guilds.delete(interaction.guild.id);
+                client.database.history.delete(interaction.guild.id);
+                nextFooter = "All data cleared";
+                continue;
+            } else {
+                nextFooter = "No changes were made";
+                continue;
+            }
+        } else {
+            let em = new Discord.MessageEmbed(pages[page].embed)
+            em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page))
+            em.setFooter({text: "Message closed"});
+            interaction.editReply({embeds: [em], components: []});
+            return
+        }
     }
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Privacy")
-        .setDescription(
-            "**Link Scanning Types**\n" +
-            "> Facebook - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" +
-            "> AMP - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
-            "**Transcripts**\n" +
-            "> Transcripts allow you to store all messages sent in a channel. This could be an issue in some cases, as they are hosted on [Pastebin](https://pastebin.com), so a leaked link could show all messages sent in the channel.\n"
-        )
-        .setStatus("Success")
-        .setEmoji("NUCLEUS.COMMANDS.LOCK")
-    ], components: components});
+    let em = new Discord.MessageEmbed(pages[page].embed)
+    em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page))
+    em.setFooter({text: "Message timed out"});
+    await interaction.editReply({
+        embeds: [em],
+        components: []
+    });
 }
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index c431d39..274dd3d 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -28,7 +28,7 @@
         .setDescription(keyValueList({
             "user": renderUser(interaction.options.getUser("user")),
             "role": renderRole(interaction.options.getRole("role"))
-        }) + `\nAre you sure you want to ${action == "give" ? "give the role to" : "remove the role from"} ${interaction.options.getUser("user")}?`)
+        }) + `\nAre you sure you want to ${action === "give" ? "give the role to" : "remove the role from"} ${interaction.options.getUser("user")}?`)
         .setColor("Danger")
     .send()
     if (confirmation.cancelled) return
@@ -36,7 +36,7 @@
         try {
             let member = interaction.options.getMember("user") as GuildMember
             let role = interaction.options.getRole("role") as Role
-            if (interaction.options.getString("action") == "give") {
+            if (interaction.options.getString("action") === "give") {
                 member.roles.add(role)
             } else {
                 member.roles.remove(role)
@@ -51,7 +51,7 @@
         }
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Role")
-            .setDescription(`The role has been ${action == "give" ? "given" : "removed"} successfully`)
+            .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
             .setStatus("Success")
             .setEmoji("GUILD.ROLES.CREATE")
         ], components: []})
@@ -69,13 +69,13 @@
     let member = (interaction.member as GuildMember)
     let me = (interaction.guild.me as GuildMember)
     let 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"
     // Check if Nucleus has permission to role
-    if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the Manage roles permission";
+    if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the *Manage Roles* permission";
     // Allow the owner to role anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user has manage_roles permission
-    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
     // Allow role
     return true;
 }
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 28e09aa..70998d5 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -31,7 +31,7 @@
                 "2 factor authentication": `${guild.mfaLevel === "NONE" ? `${getEmojiByName("CONTROL.CROSS")} No` : `${getEmojiByName("CONTROL.TICK")} Yes`}`,
                 "verification level": `${toCapitals(guild.verificationLevel)}`,
                 "explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " ", ))}`,
-                "nitro boost level": `${guild.premiumTier != "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
+                "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
                 "channels": `${guild.channels.cache.size}`,
                 "roles": `${guild.roles.cache.size}`,
                 "members": `${guild.memberCount}`,
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index df2cdb4..23d5c66 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -15,11 +16,7 @@
     .addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"))
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     let m;
     let clicked = "";
     if (interaction.options.getRole("role")) {
@@ -49,7 +46,7 @@
             .setEmoji("PUNISH.BAN.GREEN")
             .setStatus("Success")
             .setDescription(
-                "These links are shown below the message sent in a user's DM when they are warned, banned, etc.\n\n" +
+                "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([
@@ -76,13 +73,16 @@
         } 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 } } });
+                await client.database.guilds.write(interaction.guild.id, {"moderation.mute.role": null });
             } else { clicked = "clearMuteRole" }
+            continue
         } 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()
@@ -117,7 +117,7 @@
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => true)
+                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => true)
             } catch (e) { continue }
             if (out.fields) {
                 let buttonText = out.fields.getTextInputValue("name");
@@ -125,7 +125,7 @@
                 let current = chosen;
                 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 }
         }
@@ -135,7 +135,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage server permission to use this command"
+    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/attachment.ts b/src/commands/settings/logs/attachment.ts
index 0842923..2dae74e 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
 import { ChannelType } from 'discord-api-types';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
@@ -17,11 +18,7 @@
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    m = await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getChannel("channel")) {
         let channel
         try {
@@ -35,7 +32,7 @@
             ]})
         }
         channel = channel as Discord.TextChannel
-        if (channel.guild.id != interaction.guild.id) {
+        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`)
@@ -120,11 +117,11 @@
             i = await m.awaitMessageComponent({time: 300000});
         } catch(e) { break }
         i.deferUpdate()
-        if (i.component.customId == "clear") {
+        if (i.component.customId === "clear") {
             clicks += 1;
-            if (clicks == 2) {
+            if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, {}, ["logging.announcements.channel"])
+                await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"])
                 channel = undefined;
             }
         } else {
@@ -148,7 +145,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
+    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 aacc2e7..4030108 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
 import { ChannelType } from 'discord-api-types';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
@@ -17,11 +18,7 @@
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    m = await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getChannel("channel")) {
         let channel
         try {
@@ -35,7 +32,7 @@
             ]})
         }
         channel = channel as Discord.TextChannel
-        if (channel.guild.id != interaction.guild.id) {
+        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`)
@@ -115,11 +112,11 @@
             i = await m.awaitMessageComponent({time: 300000});
         } catch(e) { break }
         i.deferUpdate()
-        if (i.component.customId == "clear") {
+        if (i.component.customId === "clear") {
             clicks += 1;
-            if (clicks == 2) {
+            if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, {}, ["logging.logs.channel"])
+                await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"])
                 channel = undefined;
             }
         } else {
@@ -143,7 +140,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
+    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/staff.ts b/src/commands/settings/logs/staff.ts
index 3cb7230..5867338 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
 import { ChannelType } from 'discord-api-types';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
@@ -17,11 +18,7 @@
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    m = await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getChannel("channel")) {
         let channel
         try {
@@ -35,7 +32,7 @@
             ]})
         }
         channel = channel as Discord.TextChannel
-        if (channel.guild.id != interaction.guild.id) {
+        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`)
@@ -117,11 +114,11 @@
             i = await m.awaitMessageComponent({time: 300000});
         } catch(e) { break }
         i.deferUpdate()
-        if (i.component.customId == "clear") {
+        if (i.component.customId === "clear") {
             clicks += 1;
-            if (clicks == 2) {
+            if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, {}, ["logging.staff.channel"])
+                await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"])
                 channel = undefined;
             }
         } else {
@@ -145,7 +142,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
+    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 ec54820..6f95b46 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -17,7 +17,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the Manage roles permission to use this command"
+    if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the *Manage Roles* permission to use this command"
     return true;
 }
 
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 3159e2d..d972674 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import { ChannelType } from 'discord-api-types';
 import Discord, { AutocompleteInteraction, CommandInteraction, Message, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -8,6 +9,7 @@
 import client from "../../utils/client.js";
 import convertCurlyBracketString from '../../utils/convertCurlyBracketString.js';
 import {callback as statsChannelAddCallback} from "../../reflex/statsChannelUpdate.js";
+import singleNotify from '../../utils/singleNotify.js';
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
@@ -17,14 +19,20 @@
     .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<any> => {
+    singleNotify("statsChannelDeleted", interaction.guild.id, true)
     let m;
-    m = await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+    let config = await client.database.guilds.read(interaction.guild.id);
     if (interaction.options.getString("name")) {
-        let channel
+        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")
+            ]})
+        }
         try {
             channel = interaction.options.getChannel("channel")
         } catch {
@@ -36,7 +44,7 @@
             ]})
         }
         channel = channel as Discord.TextChannel
-        if (channel.guild.id != interaction.guild.id) {
+        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`)
@@ -51,7 +59,7 @@
         let 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}*`)
+            .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)
@@ -104,7 +112,7 @@
         await statsChannelAddCallback(client, interaction.member);
     }
     while (true) {
-        let config = await client.database.guilds.read(interaction.guild.id);
+        config = await client.database.guilds.read(interaction.guild.id);
         let stats = config.getKey("stats")
         let selectMenu = new MessageSelectMenu()
             .setCustomId("remove")
@@ -133,8 +141,7 @@
         i.deferUpdate()
         if (i.customId === "remove") {
             let toRemove = i.values;
-            console.log(toRemove.map(k => `stats.${k}`))
-            await client.database.guilds.write(interaction.guild.id, {}, toRemove.map(k => `stats.${k}`));
+            await client.database.guilds.write(interaction.guild.id, null, toRemove.map(k => `stats.${k}`));
         }
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
@@ -147,7 +154,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
+    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/tickets.ts b/src/commands/settings/tickets.ts
index 16d5f3b..f199ac3 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -21,13 +22,7 @@
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    m = await interaction.reply({
-        embeds: [new EmojiEmbed()
-            .setTitle("Loading")
-            .setStatus("Danger")
-            .setEmoji("NUCLEUS.LOADING")
-        ], ephemeral: true, fetchReply: true
-    });
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     let options = {
         enabled: interaction.options.getString("enabled") as string | boolean,
         category: interaction.options.getChannel("category"),
@@ -51,7 +46,7 @@
                 })
             }
             channel = channel as Discord.CategoryChannel
-            if (channel.guild.id != interaction.guild.id) return interaction.editReply({
+            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`)
@@ -85,7 +80,7 @@
                 })
             }
             role = role as Discord.Role
-            if (role.guild.id != interaction.guild.id) return interaction.editReply({
+            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`)
@@ -174,23 +169,23 @@
                     .setStyle(data.enabled ? "SUCCESS" : "DANGER")
                     .setCustomId("enabled"),
                 new MessageButton()
-                    .setLabel(lastClicked == "cat" ? "Click again to confirm" : "Clear category")
+                    .setLabel(lastClicked === "cat" ? "Click again to confirm" : "Clear category")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
                     .setStyle("DANGER")
                     .setCustomId("clearCategory")
-                    .setDisabled(data.category == null),
+                    .setDisabled(data.category === null),
                 new MessageButton()
-                    .setLabel(lastClicked == "max" ? "Click again to confirm" : "Reset max tickets")
+                    .setLabel(lastClicked === "max" ? "Click again to confirm" : "Reset max tickets")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
                     .setStyle("DANGER")
                     .setCustomId("clearMaxTickets")
-                    .setDisabled(data.maxTickets == 5),
+                    .setDisabled(data.maxTickets === 5),
                 new MessageButton()
-                    .setLabel(lastClicked == "sup" ? "Click again to confirm" : "Clear support ping")
+                    .setLabel(lastClicked === "sup" ? "Click again to confirm" : "Clear support ping")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
                     .setStyle("DANGER")
                     .setCustomId("clearSupportPing")
-                    .setDisabled(data.supportRole == null),
+                    .setDisabled(data.supportRole === null),
             ]), new MessageActionRow().addComponents([
                 new MessageButton()
                     .setLabel("Manage types")
@@ -204,28 +199,28 @@
             i = await m.awaitMessageComponent({ time: 300000 });
         } catch (e) { break }
         i.deferUpdate()
-        if (i.component.customId == "clearCategory") {
-            if (lastClicked == "cat") {
+        if (i.component.customId === "clearCategory") {
+            if (lastClicked === "cat") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, {}, ["tickets.category"])
+                await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"])
                 data.category = undefined;
             } else lastClicked = "cat";
-        } else if (i.component.customId == "clearMaxTickets") {
-            if (lastClicked == "max") {
+        } else if (i.component.customId === "clearMaxTickets") {
+            if (lastClicked === "max") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, {}, ["tickets.maxTickets"])
+                await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"])
                 data.maxTickets = 5;
             } else lastClicked = "max";
-        } else if (i.component.customId == "clearSupportPing") {
-            if (lastClicked == "sup") {
+        } else if (i.component.customId === "clearSupportPing") {
+            if (lastClicked === "sup") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, {}, ["tickets.supportRole"])
+                await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"])
                 data.supportRole = undefined;
             } else lastClicked = "sup";
-        } else if (i.component.customId == "enabled") {
+        } else if (i.component.customId === "enabled") {
             await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
             data.enabled = !data.enabled;
-        } else if (i.component.customId == "manageTypes") {
+        } else if (i.component.customId === "manageTypes") {
             data = await manageTypes(interaction, data, m);
         } else {
             break
@@ -329,12 +324,12 @@
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
         } catch (e) { break }
-        if (i.component.customId == "types") {
+        if (i.component.customId === "types") {
             i.deferUpdate()
             let types = toHexInteger(i.values, ticketTypes);
             await client.database.guilds.write(interaction.guild.id, { "tickets.types": types })
             data.types = types;
-        } else if (i.component.customId == "removeTypes") {
+        } else if (i.component.customId === "removeTypes") {
             i.deferUpdate()
             let types = i.values
             let customTypes = data.customTypes;
@@ -344,7 +339,7 @@
                 await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes })
                 data.customTypes = customTypes;
             }
-        } else if (i.component.customId == "addType") {
+        } 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")
@@ -371,7 +366,7 @@
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id == interaction.channel.id, (m) => m.customId == "addType")
+                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");
@@ -385,11 +380,11 @@
                     data.customTypes.push(toAdd);
                 }
             } else { continue }
-        } else if (i.component.customId == "switchToDefault") {
+        } else if (i.component.customId === "switchToDefault") {
             i.deferUpdate()
             await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, [])
             data.useCustom = false;
-        } else if (i.component.customId == "switchToCustom") {
+        } else if (i.component.customId === "switchToCustom") {
             i.deferUpdate()
             await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, [])
             data.useCustom = true;
@@ -404,7 +399,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
+    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 d71fdf0..14dfe8d 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -14,11 +15,7 @@
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    m = await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getRole("role")) {
         let role
         try {
@@ -32,7 +29,7 @@
             ]})
         }
         role = role as Discord.Role
-        if (role.guild.id != interaction.guild.id) {
+        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`)
@@ -100,23 +97,24 @@
             .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)
+        ], 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)
         ])]});
         let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
         } catch(e) { break }
         i.deferUpdate()
-        if (i.component.customId == "clear") {
+        if (i.component.customId === "clear") {
             clicks += 1;
-            if (clicks == 2) {
+            if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, {}, ["verify.role", "verify.enabled"])
+                await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"])
                 role = undefined;
             }
         } else {
@@ -134,13 +132,13 @@
         .setLabel("Clear")
         .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
         .setStyle("SECONDARY")
-        .setDisabled(true)
+        .setDisabled(true),
     ])]});
 }
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the Manage Server permission to use this command"
+    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/tag.ts b/src/commands/tag.ts
index 0c44e37..03b13c6 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -55,4 +55,4 @@
 export { command };
 export { callback };
 export { check };
-export { autocomplete };
\ No newline at end of file
+export { autocomplete };
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index 0e0d54d..b0a278d 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -79,7 +79,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the Manage Messages permission to use this command"
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Server* permission to use this command"
     return true;
 }
 
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index f531e93..68a02d4 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -60,7 +60,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the Manage Messages permission to use this command"
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command"
     return true;
 }
 
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 2ecdfbf..2f585cd 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -75,7 +75,7 @@
             toUnset.push(`tags.${name}`);
             toSet[`tags.${newname}`] = data.tags[name];
         }
-        await client.database.guilds.write(interaction.guild.id, toSet, toUnset);
+        await client.database.guilds.write(interaction.guild.id, toSet === {} ? null : toSet, toUnset);
     } catch (e) {
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Tag Edit")
@@ -94,7 +94,7 @@
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the Manage Messages permission to use this command"
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command"
     return true;
 }
 
diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts
index a534791..c335267 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -53,15 +54,7 @@
             ).setTitle(`Page ${pages.length + 1}`).setPageId(pages.length))
     }
     let m;
-    m = await interaction.reply({
-        embeds: [
-            new EmojiEmbed()
-                .setTitle("Welcome")
-                .setDescription(`One moment...`)
-                .setStatus("Danger")
-                .setEmoji("NUCLEUS.LOADING")
-        ], fetchReply: true, ephemeral: true
-    });
+    m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
     let page = 0;
     let selectPaneOpen = false;
     while (true) {
@@ -100,15 +93,15 @@
             i = await m.awaitMessageComponent({time: 300000 });
         } catch (e) { break }
         i.deferUpdate()
-        if (i.component.customId == "left") {
+        if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
-        } else if (i.component.customId == "right") {
+        } else if (i.component.customId === "right") {
             if (page < pages.length - 1) page++;
             selectPaneOpen = false;
-        } else if (i.component.customId == "select") {
+        } else if (i.component.customId === "select") {
             selectPaneOpen = !selectPaneOpen;
-        } else if (i.component.customId == "page") {
+        } else if (i.component.customId === "page") {
             page = parseInt(i.values[0]);
             selectPaneOpen = false;
         } else {
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 8557d15..82eda6a 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -64,7 +65,7 @@
     membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp)
     let joinPos = membersArray.findIndex(m => m.id === member.user.id)
 
-    let roles = member.roles.cache.filter(r => r.id != interaction.guild.id).sort()
+    let roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort()
     let s = "";
     let count = 0;
     let ended = false
@@ -158,7 +159,7 @@
             ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2),
     ]
     let m
-    m = await interaction.reply({embeds: [new EmojiEmbed().setTitle("Loading").setEmoji("NUCLEUS.LOADING").setStatus("Danger")], fetchReply: true, ephemeral: true});
+    m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
     let page = 0
     let breakReason = ""
     while (true) {
@@ -212,18 +213,18 @@
             i = await m.awaitMessageComponent({time: 300000});
         } catch { breakReason = "Message timed out"; break }
         i.deferUpdate()
-        if (i.component.customId == "left") {
+        if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
-        } else if (i.component.customId == "right") {
+        } else if (i.component.customId === "right") {
             if (page < embeds.length - 1) page++;
             selectPaneOpen = false;
-        } else if (i.component.customId == "select") {
+        } else if (i.component.customId === "select") {
             selectPaneOpen = !selectPaneOpen;
-        } else if (i.component.customId == "close") {
+        } else if (i.component.customId === "close") {
             breakReason = "Message closed";
             break;
-        } else if (i.component.customId == "page") {
+        } else if (i.component.customId === "page") {
             page = parseInt(i.values[0]);
             selectPaneOpen = false;
         } else {
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index 54af9d7..f6c1df1 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
 import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
 import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -15,9 +16,9 @@
 const generateFromTrack = (position: number, active: any, size: number, disabled: any) => {
     active = active ? "ACTIVE" : "INACTIVE"
     disabled = disabled ? "GREY." : ""
-    if (position == 0 && size == 1) return "TRACKS.SINGLE." + disabled + active
-    if (position == size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active
-    if (position == 0) return "TRACKS.VERTICAL.TOP." + disabled + active
+    if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active
+    if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active
+    if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active
     return "TRACKS.VERTICAL.MIDDLE." + disabled + active
 }
 
@@ -26,11 +27,7 @@
     const member = interaction.options.getMember("user") as GuildMember;
     const guild = interaction.guild;
     let config = await client.database.guilds.read(guild.id);
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setEmoji("NUCLEUS.LOADING")
-        .setTitle("Loading")
-        .setStatus("Danger")
-    ], ephemeral: true})
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
     let track = 0
     let generated;
     const roles = await guild.roles.fetch()
@@ -43,10 +40,10 @@
         let dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
             let hasRoleInTrack = option.track.some(element => {return memberRoles.cache.has(element)})
             return new SelectMenuOption({
-                default: index == track,
+                default: index === track,
                 label: option.name,
                 value: index.toString(),
-                description: option.track.length == 0 ? "No" : addPlural(option.track.length, "role"),
+                description: option.track.length === 0 ? "No" : addPlural(option.track.length, "role"),
                 emoji: client.emojis.resolve(getEmojiByName("TRACKS.SINGLE." + (hasRoleInTrack ? "ACTIVE" : "INACTIVE"), "id"))
             })
         })).setCustomId("select").setMaxValues(1)
@@ -94,7 +91,7 @@
                 generated += "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep."
             }
         } else {
-            currentRoleIndex = selected.length == 0 ? -1 : data.track.indexOf(selected[0].toString())
+            currentRoleIndex = selected.length === 0 ? -1 : data.track.indexOf(selected[0].toString())
         }
         let m = await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("TRACKS.ICON")
@@ -112,7 +109,7 @@
                     .setLabel("Move up")
                     .setCustomId("promote")
                     .setStyle("SUCCESS")
-                    .setDisabled(conflict || currentRoleIndex == 0 || (currentRoleIndex == -1 ? false : !allowed[currentRoleIndex - 1])),
+                    .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
                 new MessageButton()
                     .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
                     .setLabel("Move down")
@@ -120,7 +117,7 @@
                     .setStyle("DANGER")
                     .setDisabled(conflict || (
                         data.nullable ? currentRoleIndex <= -1 :
-                        currentRoleIndex == data.track.length - 1 || currentRoleIndex <= -1
+                        currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
                     ) || !allowed[currentRoleIndex]),
             ])
         ])})
@@ -131,31 +128,31 @@
             return
         }
         component.deferUpdate()
-        if (component.customId == "conflict") {
-            let rolesToRemove = selected.filter(role => role != component.values[0])
+        if (component.customId === "conflict") {
+            let rolesToRemove = selected.filter(role => role !== component.values[0])
             await member.roles.remove(rolesToRemove)
-        } else if (component.customId == "promote") {
+        } else if (component.customId === "promote") {
             if (
-                currentRoleIndex == -1 ? allowed[data.track.length - 1] :
+                currentRoleIndex === -1 ? allowed[data.track.length - 1] :
                 allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
             ) {
-                if (currentRoleIndex == -1) {
+                if (currentRoleIndex === -1) {
                     await member.roles.add(data.track[data.track.length - 1])
                 } else if (currentRoleIndex < data.track.length) {
                     if (!data.retainPrevious) await member.roles.remove(data.track[currentRoleIndex])
                     await member.roles.add(data.track[currentRoleIndex - 1])
                 }
             }
-        } else if (component.customId == "demote") {
+        } else if (component.customId === "demote") {
             if(allowed[currentRoleIndex]) {
-                if (currentRoleIndex == data.track.length - 1) {
+                if (currentRoleIndex === data.track.length - 1) {
                     if (data.nullable) await member.roles.remove(data.track[currentRoleIndex])
                 } else if (currentRoleIndex > -1) {
                     await member.roles.remove(data.track[currentRoleIndex])
                     await member.roles.add(data.track[currentRoleIndex + 1])
                 }
             }
-        } else if (component.customId == "select") {
+        } else if (component.customId === "select") {
             track = component.values[0]
         }
     }
@@ -166,7 +163,7 @@
     if (tracks.length === 0) throw "This server does not have any tracks"
     let member = (interaction.member as GuildMember)
     // Allow the owner to promote anyone
-    if (member.id == interaction.guild.ownerId) return true
+    if (member.id === interaction.guild.ownerId) return true
     // Check if the user can manage any of the tracks
     let managed = false
     tracks.forEach(element => {
@@ -174,7 +171,7 @@
         if (element.track.manageableBy.some(role => member.roles.cache.has(role))) managed = true
     });
     // Check if the user has manage_roles permission
-    if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the Manage roles permission";
+    if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
     // Allow track
     return true;
 }
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index 2d48255..fa66755 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -4,8 +4,8 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
         let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+        if (audit.executor.id === client.user.id) return;
         let emoji;
         let readableType;
         let displayName;
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index ffe3eae..25c9ce5 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -7,8 +7,8 @@
         const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
 
         let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+        if (audit.executor.id === client.user.id) return;
 
         let emoji;
         let readableType;
@@ -49,7 +49,7 @@
             deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
             deletedBy: entry(audit.executor.id, renderUser(audit.executor))
         }
-        if (channel.topic != null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
+        if (channel.topic !== null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
         else delete list.topic;
         if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
         else delete list.nsfw;
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 50a3de1..568af0b 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -8,11 +8,11 @@
         let config = await client.memory.readGuildInfo(nc.guild.id);
         const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
 
-        if (nc.parent && (nc.parent.id == config.tickets.category)) return
+        if (nc.parent && (nc.parent.id === config.tickets.category)) return
 
         let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == nc.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
+        if (audit.executor.id === client.user.id) return;
 
         let emoji:string;
         let readableType:string;
@@ -23,8 +23,8 @@
             edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
             editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
         }
-        if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
-        if (oc.position != nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
+        if (oc.name !== nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+        if (oc.position !== nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
 
         switch (nc.type) {
             case 'GUILD_TEXT': {
@@ -43,9 +43,9 @@
                 let nsfw = ["", ""]
                 nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
                 nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-                if (oc.topic != nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
-                if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
-                if (oc.rateLimitPerUser != nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
+                if (oc.topic !== nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+                if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
+                if (oc.rateLimitPerUser !== nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
                     [oc.rateLimitPerUser, nc.rateLimitPerUser],
                     `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
                 );
@@ -65,16 +65,16 @@
                     if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
                     else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
                 } else { newTopic = "None"; }
-                if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
+                if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
                 break;
             }
             case 'GUILD_VOICE': {
                 emoji = "CHANNEL.VOICE.EDIT";
                 readableType = "Voice";
                 displayName = "Voice Channel"
-                if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
-                if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
-                if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+                if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+                if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+                if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
                     [oc.rtcRegion, nc.rtcRegion],
                     `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
                 );
@@ -93,9 +93,9 @@
                     if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
                     else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
                 } else { newTopic = "None"; }
-                if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
-                if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
-                if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+                if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+                if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+                if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
                     [oc.rtcRegion, nc.rtcRegion],
                     `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
                 );
@@ -114,7 +114,7 @@
             }
         }
         let t = oc.type.split("_")[1];
-        if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
+        if (oc.type !== nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
         if (!(Object.values(changes).length - 4)) return
         let data = {
             meta:{
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 25d1b62..9e91012 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -4,8 +4,8 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
         let auditLog = await getAuditLog(emoji.guild, 'EMOJI_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'emojiCreate',
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 2dcb685..0c39542 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -4,8 +4,8 @@
     try{
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
         let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'emojiDelete',
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 79fb171..a90de9a 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -6,10 +6,10 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
 
-        if (oe.name == ne.name) return
+        if (oe.name === ne.name) return
         let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
         let audit = auditLog.entries.first();
-        if (audit.executor.id == client.user.id) return;
+        if (audit.executor.id === client.user.id) return;
 
         let changes = {
             emojiId: entry(ne.id, `\`${ne.id}\``),
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index d095049..06163a9 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -9,8 +9,8 @@
     try {
         const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
         let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_ADD')
-        let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first();
-        if (audit.executor.id == client.user.id) return
+        let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+        if (audit.executor.id === client.user.id) return
         try { await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
         let data = {
             meta: {
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 4d6d1f8..2a1b6de 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -10,8 +10,8 @@
     try {
         const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
         let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_REMOVE')
-        let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first();
-        if (audit.executor.id == client.user.id) return
+        let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+        if (audit.executor.id === client.user.id) return
         try { await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
         let data = {
             meta: {
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index e68aee4..d555647 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -4,9 +4,9 @@
     try {
         const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger
         let auditLog = await getAuditLog(after.guild, 'MEMBER_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
-        if (audit.executor.id == client.user.id) return;
-        if (before.nickname != after.nickname) {
+        let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+        if (audit.executor.id === client.user.id) return;
+        if (before.nickname !== after.nickname) {
             try { await client.database.history.create(
                 "nickname", after.guild.id, after.user, audit.executor,
                 null, before.nickname || before.user.username, after.nickname || after.user.username) } catch {}
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index ee02b66..e27975b 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,11 +1,14 @@
+import { callback as statsChannelUpdate } from '../reflex/statsChannelUpdate.js';
+
 export const event = 'guildUpdate'
 
 export async function callback(client, before, after) {
+    try { await statsChannelUpdate(client, after.me); } catch(e) { console.log(e)}
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger
         let auditLog = await getAuditLog(after, 'GUILD_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+        if (audit.executor.id === client.user.id) return;
         let list = {}
 
         const verificationLevels = {
@@ -27,14 +30,14 @@
             ELEVATED: 'Enabled'
         }
 
-        if (before.name != after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
-        if (before.icon != after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
-        if (before.splash != after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
-        if (before.banner != after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
-        if (before.owner != after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
-        if (before.verificationLevel != after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
-        if (before.explicitContentFilter != after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
-        if (before.mfaLevel != after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
+        if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+        if (before.icon !== after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
+        if (before.splash !== after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
+        if (before.banner !== after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
+        if (before.owner !== after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
+        if (before.verificationLevel !== after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
+        if (before.explicitContentFilter !== after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
+        if (before.mfaLevel !== after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
 
         if (!(Object.keys(list).length)) return;
         list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 5081dd1..5d47bf8 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -5,8 +5,8 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
         let auditLog = await getAuditLog(invite.guild, 'INVITE_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'inviteCreate',
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index b6ddd22..acfc9dd 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -5,8 +5,8 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
         let auditLog = await getAuditLog(invite.guild, 'INVITE_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'inviteDelete',
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 122e01a..5dff86f 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,4 +1,3 @@
-import humanizeDuration from 'humanize-duration';
 import { purgeByUser } from '../actions/tickets/delete.js';
 import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
 
@@ -6,10 +5,11 @@
 
 export async function callback(client, member) {
     try { purgeByUser(member.id, member.guild); } catch {}
+    try { await statsChannelRemove(client, member); } catch {}
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
         let auditLog = await getAuditLog(member.guild, 'MEMBER_KICK');
-        let audit = auditLog.entries.filter(entry => entry.target.id == member.id).first();
+        let audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
         let type = "leave"
         if (audit) {
             if (audit.executor.id === client.user.id) return
@@ -18,7 +18,7 @@
             }
         }
         let data
-        if (type == "kick") {
+        if (type === "kick") {
             try { await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason) } catch {}
             data = {
                 meta: {
@@ -36,7 +36,6 @@
                     kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
                     reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
-                    timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
                     accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
                     serverMemberCount: member.guild.memberCount,
                 },
@@ -60,7 +59,6 @@
                     name: entry(member.id, renderUser(member.user)),
                     joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
                     left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                    timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
                     accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
                     serverMemberCount: member.guild.memberCount,
                 },
@@ -71,5 +69,4 @@
         }
         log(data);
     } catch (e) { console.log(e) }
-    try { await statsChannelRemove(client, member); } catch {}
 }
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index dce1959..cbb1fa2 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,14 +1,17 @@
 import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../reflex/scanners.js'
 import logAttachment from '../premium/attachmentLogs.js'
 import createLogException from '../utils/createLogException.js'
-import getEmojiByName from '../utils/getEmojiByName.js'
+import getEmojiByName from '../utils/getEmojiByName.js';
+import client from '../utils/client.js';
+import {callback as a} from '../reflex/statsChannelUpdate.js'
 
 export const event = 'messageCreate'
 
-export async function callback(client, message) {
+export async function callback(_, message) {
     if(!message) return;
     if (message.author.bot) return
     if (message.channel.type === 'dm') return
+    try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e)}
 
     const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger
 
@@ -66,7 +69,7 @@
         for (let element of fileNames.files) {
             if(!message) return;
             let url = element.url ? element.url : element.local
-            if (url != undefined) {
+            if (url !== undefined) {
                 if(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)) {
                     if (config.filters.images.NSFW && !message.channel.nsfw) {
                         if (await NSFWCheck(url)) {
@@ -94,30 +97,28 @@
                     }
                     if (config.filters.wordFilter.enabled) {
                         let text = await TestImage(url)
-                        if (config.filters.wordFilter.enabled) {
-                            let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
-                            if(check !== null) {
-                                createLogException(message.guild.id, message.channel.id, message.id)
-                                await message.delete()
-                                let data = {
-                                    meta: {
-                                        type: 'messageDelete',
-                                        displayName: 'Message Deleted',
-                                        calculateType: 'autoModeratorDeleted',
-                                        color: NucleusColors.red,
-                                        emoji: 'MESSAGE.DELETE',
-                                        timestamp: new Date().getTime()
-                                    },
-                                    separate: {
-                                        start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
-                                    },
-                                    list: list,
-                                    hidden: {
-                                        guild: message.channel.guild.id
-                                    }
+                        let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+                        if(check !== null) {
+                            createLogException(message.guild.id, message.channel.id, message.id)
+                            await message.delete()
+                            let data = {
+                                meta: {
+                                    type: 'messageDelete',
+                                    displayName: 'Message Deleted',
+                                    calculateType: 'autoModeratorDeleted',
+                                    color: NucleusColors.red,
+                                    emoji: 'MESSAGE.DELETE',
+                                    timestamp: new Date().getTime()
+                                },
+                                separate: {
+                                    start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                },
+                                list: list,
+                                hidden: {
+                                    guild: message.channel.guild.id
                                 }
-                                return log(data);
                             }
+                            return log(data);
                         }
                     }
                     if (config.filters.images.size) {
@@ -199,6 +200,7 @@
         }
         return log(data);
     }
+
     if (config.filters.wordFilter.enabled) {
         let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
         if(check !== null) {
@@ -225,78 +227,73 @@
         }
     }
 
-    if (!config.filters.pings.allowed.users.includes(message.author.id) ||
-        !config.filters.pings.allowed.channels.includes(message.channel.id) ||
-        !message.author.roles.cache.some(role => config.filters.pings.allowed.roles.includes(role.id))
-    ) {
-        if (config.filters.pings.everyone && message.mentions.everyone) {
-            let data = {
-                meta: {
-                    type: 'everyonePing',
-                    displayName: 'Everyone Pinged',
-                    calculateType: 'messageMassPing',
-                    color: NucleusColors.yellow,
-                    emoji: 'MESSAGE.PING.EVERYONE',
-                    timestamp: new Date().getTime()
-                },
-                separate: {
-                    start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
-                },
-                list: list,
-                hidden: {
-                    guild: message.channel.guild.id
-                }
+    if (config.filters.pings.everyone && message.mentions.everyone) {
+        let data = {
+            meta: {
+                type: 'everyonePing',
+                displayName: 'Everyone Pinged',
+                calculateType: 'messageMassPing',
+                color: NucleusColors.yellow,
+                emoji: 'MESSAGE.PING.EVERYONE',
+                timestamp: new Date().getTime()
+            },
+            separate: {
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+            },
+            list: list,
+            hidden: {
+                guild: message.channel.guild.id
             }
-            return log(data);
         }
-        if (config.filters.pings.roles) {
-            for(let role of message.mentions.roles) {
-                if(!message) return;
-                if (!config.filters.pings.allowed.roles.includes(role.id)) {
-                    createLogException(message.guild.id, message.channel.id, message.id)
-                    await message.delete()
-                    let data = {
-                        meta: {
-                            type: 'rolePing',
-                            displayName: 'Role Pinged',
-                            calculateType: 'messageMassPing',
-                            color: NucleusColors.yellow,
-                            emoji: 'MESSAGE.PING.ROLE',
-                            timestamp: new Date().getTime()
-                        },
-                        separate: {
-                            start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
-                        },
-                        list: list,
-                        hidden: {
-                            guild: message.channel.guild.id
-                        }
+        return log(data);
+    }
+    if (config.filters.pings.roles) {
+        for(let role of message.mentions.roles) {
+            if(!message) return;
+            if (!config.filters.pings.allowed.roles.includes(role.id)) {
+                createLogException(message.guild.id, message.channel.id, message.id)
+                await message.delete()
+                let data = {
+                    meta: {
+                        type: 'rolePing',
+                        displayName: 'Role Pinged',
+                        calculateType: 'messageMassPing',
+                        color: NucleusColors.yellow,
+                        emoji: 'MESSAGE.PING.ROLE',
+                        timestamp: new Date().getTime()
+                    },
+                    separate: {
+                        start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                    },
+                    list: list,
+                    hidden: {
+                        guild: message.channel.guild.id
                     }
-                    return log(data);
                 }
+                return log(data);
             }
         }
-        if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
-            createLogException(message.guild.id, message.channel.id, message.id)
-            await message.delete()
-            let data = {
-                meta: {
-                    type: 'massPing',
-                    displayName: `Mass Ping`,
-                    calculateType: 'messageMassPing',
-                    color: NucleusColors.yellow,
-                    emoji: 'MESSAGE.PING.MASS',
-                    timestamp: new Date().getTime()
-                },
-                separate: {
-                    start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
-                },
-                list: list,
-                hidden: {
-                    guild: message.channel.guild.id
-                }
+    }
+    if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
+        createLogException(message.guild.id, message.channel.id, message.id)
+        await message.delete()
+        let data = {
+            meta: {
+                type: 'massPing',
+                displayName: `Mass Ping`,
+                calculateType: 'messageMassPing',
+                color: NucleusColors.yellow,
+                emoji: 'MESSAGE.PING.MASS',
+                timestamp: new Date().getTime()
+            },
+            separate: {
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+            },
+            list: list,
+            hidden: {
+                guild: message.channel.guild.id
             }
-            return log(data);
         }
+        return log(data);
     }
 }
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 3c23739..b139297 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -2,11 +2,11 @@
 
 export async function callback(client, message) {
     try {
-        if (message.author.id == client.user.id) return;
+        if (message.author.id === client.user.id) return;
         if (client.noLog.includes(`${message.guild.id}/${message.channel.id}/${message.id}`)) return;
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
         let auditLog = await getAuditLog(message.guild, 'MEMBER_BAN_ADD')
-        let audit = auditLog.entries.filter(entry => entry.target.id == message.author.id).first();
+        let audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
         if (audit) {
             if (audit.createdAt - 100 < new Date().getTime()) return;
         }
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 5e63797..9e0e521 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,7 +2,7 @@
 
 export async function callback(client, oldMessage, newMessage) {
     try {
-        if (newMessage.author.id == client.user.id) return;
+        if (newMessage.author.id === client.user.id) return;
         const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
         newMessage.reference = newMessage.reference || {}
         let newContent = newMessage.cleanContent.replaceAll("`", "‘")
@@ -10,7 +10,7 @@
         let attachmentJump = "";
         let config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[newMessage.channel.id + newMessage.id];
         if (config) { attachmentJump = ` [[View attachments]](${config})` }
-        if (newContent == oldContent) {
+        if (newContent === oldContent) {
             if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
                 let data = {
                     meta: {
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 6fded26..2f159ac 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -5,8 +5,8 @@
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
         if (role.managed) return;
         let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'roleCreate',
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 6a23d9e..3b43a55 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -7,8 +7,8 @@
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
         if (role.managed) return;
         let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'roleDelete',
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 7c6ca75..7c03c97 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -8,7 +8,7 @@
 
         let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
         let audit = auditLog.entries.first();
-        if (audit.executor.id == client.user.id) return;
+        if (audit.executor.id === client.user.id) return;
 
         let changes = {
             roleId: entry(nr.id, `\`${nr.id}\``),
@@ -22,13 +22,13 @@
         mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
         hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
         hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-        if (or.name != nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
-        if (or.position != nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
-        if (or.hoist != nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
-        if (or.mentionable != nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
-        if (or.hexColor != nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
+        if (or.name !== nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
+        if (or.position !== nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
+        if (or.hoist !== nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
+        if (or.mentionable !== nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+        if (or.hexColor !== nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
 
-        if (Object.keys(changes).length == 4) return
+        if (Object.keys(changes).length === 4) return
 
         let data = {
             meta:{
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index b9511b0..669de32 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -4,8 +4,8 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
         let auditLog = await getAuditLog(emoji.guild, 'STICKER_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'stickerCreate',
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 7490851..0431bda 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -4,8 +4,8 @@
     try{
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
         let auditLog = await getAuditLog(emoji.guild, 'STICKER_DELETE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'stickerDelete',
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 7cb745f..363e072 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -4,10 +4,10 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
 
-        if (oe.name == ne.name) return
+        if (oe.name === ne.name) return
         let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
         let audit = auditLog.entries.first();
-        if (audit.executor.id == client.user.id) return;
+        if (audit.executor.id === client.user.id) return;
 
         let changes = {
             stickerId:entry(ne.id, `\`${ne.id}\``),
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index ff69e35..ef7246d 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -5,8 +5,8 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
         let auditLog = await getAuditLog(thread.guild, 'THREAD_CREATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == thread.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+        if (audit.executor.id === client.user.id) return;
         let data = {
             meta: {
                 type: 'channelCreate',
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 14c5820..9574826 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -5,8 +5,8 @@
     try {
     const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
     let auditLog = await getAuditLog(thread.guild, 'THREAD_UPDATE');
-    let audit = auditLog.entries.filter(entry => entry.target.id == thread.id).first();
-    if (audit.executor.id == client.user.id) return;
+    let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+    if (audit.executor.id === client.user.id) return;
     let data = {
         meta: {
             type: 'channelDelete',
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 4e13193..8550ffe 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -5,20 +5,20 @@
     try {
         const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger
         let auditLog = await getAuditLog(after.guild, 'THREAD_UPDATE');
-        let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
-        if (audit.executor.id == client.user.id) return;
+        let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+        if (audit.executor.id === client.user.id) return;
         let list = {
             threadId:entry(after.id, `\`${after.id}\``),
             thread: entry(after.name, renderChannel(after)),
             parentChannel: entry(after.parentId, renderChannel(after.parent)),
         }
-        if (before.name != after.name) {
+        if (before.name !== after.name) {
             list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
         }
-        if (before.autoArchiveDuration != after.autoArchiveDuration) {
+        if (before.autoArchiveDuration !== after.autoArchiveDuration) {
             list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
         }
-        if (before.rateLimitPerUser != after.rateLimitPerUser) {
+        if (before.rateLimitPerUser !== after.rateLimitPerUser) {
             list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
         }
         if (!(Object.keys(list).length - 3)) return;
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 66b1cd0..28768b2 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -8,9 +8,9 @@
         let auditLogUpdate = getAuditLog(channel.guild, 'WEBHOOK_UPDATE');
         let auditLogDelete = getAuditLog(channel.guild, 'WEBHOOK_DELETE');
         [auditLogCreate, auditLogUpdate, auditLogDelete] = await Promise.all([auditLogCreate, auditLogUpdate, auditLogDelete]);
-        let auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId == channel.id).first();
-        let auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId == channel.id).first();
-        let auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId == channel.id).first();
+        let auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
+        let auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
+        let auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
         if (!auditCreate && !auditUpdate && !auditDelete) return;
         let audit = auditCreate;
         let action = "Create";
diff --git a/src/premium/attachmentLogs.ts b/src/premium/attachmentLogs.ts
index e1dfcc0..ed9a4ab 100644
--- a/src/premium/attachmentLogs.ts
+++ b/src/premium/attachmentLogs.ts
@@ -18,7 +18,7 @@
             attachments.push({local: await saveAttachment(link), url: link})
         }
     }
-    if (attachments.length == 0) return {files: []}
+    if (attachments.length === 0) return {files: []}
     if (client.database.premium.hasPremium(message.guild.id)) {
         let channel = (await client.database.guilds.read(message.guild.id)).logging.attachments.channel;
         if (!channel) {
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index 92b268c..55697b9 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -13,7 +13,7 @@
     let messages = []
     let deleted = 100;
 
-    while (deleted == 100) {
+    while (deleted === 100) {
         let fetched;
         await (interaction.channel as TextChannel).messages.fetch({limit: 100}).then(async (ms) => {
             fetched = await (interaction.channel as TextChannel).bulkDelete(ms, true);
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 39974e7..517d7f4 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
 import { SelectMenuOption } from '@discordjs/builders';
 import Discord, { MessageActionRow, MessageButton } from "discord.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -126,23 +127,8 @@
             ).setTitle("Premium").setDescription("Premium features").setPageId(7),
     ]
     let m;
-    if (interaction) {
-        m = await interaction.reply({embeds: [
-            new EmojiEmbed()
-                .setTitle("Welcome")
-                .setDescription(`One moment...`)
-                .setStatus("Danger")
-                .setEmoji("NUCLEUS.LOADING")
-        ], fetchReply: true, ephemeral: true});
-    } else {
-        m = await c.send({embeds: [
-            new EmojiEmbed()
-                .setTitle("Welcome")
-                .setDescription(`One moment...`)
-                .setStatus("Danger")
-                .setEmoji("NUCLEUS.LOADING")
-        ], fetchReply: true });
-    }
+    if (interaction) { m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true}); }
+    else { m = await c.send({embeds: LoadingEmbed }); }
     let page = 0;
 
     let f = async (component) => {
@@ -174,8 +160,7 @@
         let components = selectPane.concat([new MessageActionRow().addComponents([
             new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
             new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
-            new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1),
-            new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER")
+            new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1)
         ])])
         if (interaction) {
             let em = new Discord.MessageEmbed(pages[page].embed)
@@ -198,56 +183,53 @@
             i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, time: 300000});
         } catch(e) { break }
         i.deferUpdate()
-        if (i.component.customId == "left") {
+        if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
-        } else if (i.component.customId == "right") {
+        } else if (i.component.customId === "right") {
             if (page < pages.length - 1) page++;
             selectPaneOpen = false;
-        } else if (i.component.customId == "select") {
+        } else if (i.component.customId === "select") {
             selectPaneOpen = !selectPaneOpen;
-        } else if (i.component.customId == "page") {
+        } else if (i.component.customId === "page") {
             page = parseInt(i.values[0]);
             selectPaneOpen = false;
         } else {
             if (interaction) {
                 let em = new Discord.MessageEmbed(pages[page].embed)
-                em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message closed");
+                em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
+                em.setFooter({text: "Message closed"})
                 interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
                     new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
                     new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(true),
-                    new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
-                    new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
-                ])], fetchReply: true});
+                    new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true)
+                ])]});
             } else {
                 m.delete();
             }
             return;
         }
     }
-    const { NucleusColors } = client.logger
     if (interaction) {
         let em = new Discord.MessageEmbed(pages[page].embed)
-        em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out").setColor(NucleusColors.Danger);
+        em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
         await interaction.editReply({
             embeds: [em],
             components: [new MessageActionRow().addComponents([
                 new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
                 new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
-                new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
-                new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
+                new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true)
             ])]
         });
     } else {
         let em = new Discord.MessageEmbed(pages[page].embed)
-        em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out").setColor(NucleusColors.Danger);
+        em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
         await m.edit({
             embeds: [em],
             components: [new MessageActionRow().addComponents([
                 new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
                 new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle("SECONDARY").setDisabled(true),
-                new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true),
-                new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
+                new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(true)
             ])]
         });
     }
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index a1a5974..3b80816 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -84,7 +84,7 @@
 }
 
 export async function SizeCheck(element): Promise<boolean> {
-    if (element.height == undefined || element.width == undefined) return true
+    if (element.height === undefined || element.width === undefined) return true
     if (element.height < 20 || element.width < 20) return false
     return true
 }
@@ -105,7 +105,7 @@
     }
     for(let word of soft) {
         for(let word2 of string.match(/[a-z]+/gi) || []) {
-            if (word2 == word) {
+            if (word2 === word) {
                 return {word: word, type: "strict"}
             }
         }
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index 7d04c8f..b306ecc 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -17,15 +17,20 @@
                 fetchedChannel = await guild.channels.fetch(channel)
             } catch (e) { fetchedChannel = null }
             if (!fetchedChannel) {
+                let deleted = config.getKey("stats")[channel]
+                console.log(`stats.${channel}`)
+                console.log(guild.id)
+                await client.database.guilds.write(guild.id, null, `stats.${channel}`)
                 return singleNotify(
                     "statsChannelDeleted",
                     guild.id,
-                    "One or more of your stats channels have been deleted. Please open the settings menu to change this.",
+                    "One or more of your stats channels have been deleted. Please use `/settings stats` if you wish to add the channel again.\n" +
+                    `The channels name was: ${deleted.name}`,
                     "Critical"
                 )
             }
             try {
-                await fetchedChannel.setName(string)
+                await fetchedChannel.setName(string.slice(0, 100))
             } catch (e) {
                 console.error(e)
             }
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index 9d90dde..b95cdb7 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,3 +1,4 @@
+import { LoadingEmbed } from './../utils/defaultEmbeds.js';
 import Discord, { GuildMember } from "discord.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import fetch from "node-fetch";
@@ -11,12 +12,7 @@
 
 export default async function(interaction) {
     let verify = client.verify
-    await interaction.reply({embeds: [new EmojiEmbed()
-        .setTitle("Loading")
-        .setDescription(step(-1))
-        .setStatus("Danger")
-        .setEmoji("NUCLEUS.LOADING")
-    ], ephemeral: true, fetchReply: true});
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     let config = await client.database.guilds.read(interaction.guild.id);
     if ((!config.verify.enabled ) || (!config.verify.role)) return interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
@@ -40,7 +36,7 @@
     ]});
     try {
         let status = await fetch(client.config.baseUrl).then(res => res.status);
-        if (status != 200) {
+        if (status !== 200) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify")
                 .setDescription(`Our servers appear to be down, please try again later` + step(0))
diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts
index 6b8c058..8badc58 100644
--- a/src/utils/calculate.ts
+++ b/src/utils/calculate.ts
@@ -49,7 +49,7 @@
     let permissions = [];
     let int = (BigInt("0x" + permissionsHex)).toString(2).split('').reverse();
     for (let index in int) {
-        if (int[index] == "1" && array.length > index) {
+        if (int[index] === "1" && array.length > index) {
             permissions.push(array[index]);
         }
     }
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 988fd37..dfdc3fb 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -148,7 +148,7 @@
                 });
                 let out;
                 try {
-                    out = await modalInteractionCollector(m, (m) => m.channel.id == this.interaction.channel.id, (m) => m.customId == "reason")
+                    out = await modalInteractionCollector(m, (m) => m.channel.id === this.interaction.channel.id, (m) => m.customId === "reason")
                 } catch (e) { return {} }
                 if (out.fields) { return { newReason: out.fields.getTextInputValue("reason") ?? "" }; }
                 else { return { newReason: this.reason } }
diff --git a/src/utils/createPageIndicator.ts b/src/utils/createPageIndicator.ts
index 8e18e30..fa203dc 100644
--- a/src/utils/createPageIndicator.ts
+++ b/src/utils/createPageIndicator.ts
@@ -3,13 +3,13 @@
 function pageIndicator(amount: number, selected: number, showDetails?: boolean | true) {
     let out = "";
 
-    if (amount == 1) {
-        out += getEmojiByName("TRACKS.SINGLE." + (selected == 0 ? "ACTIVE" : "INACTIVE"));
+    if (amount === 1) {
+        out += getEmojiByName("TRACKS.SINGLE." + (selected === 0 ? "ACTIVE" : "INACTIVE"));
     } else {
         for (let i = 0; i < amount; i++) {
             out += getEmojiByName("TRACKS.HORIZONTAL." +
-                (i == 0 ? "LEFT" : (i == amount - 1 ? "RIGHT" : "MIDDLE")) + "." +
-                (i == selected ? "ACTIVE" : "INACTIVE")
+                (i === 0 ? "LEFT" : (i === amount - 1 ? "RIGHT" : "MIDDLE")) + "." +
+                (i === selected ? "ACTIVE" : "INACTIVE")
             );
         }
     }
diff --git a/src/utils/database.ts b/src/utils/database.ts
index d24c7bf..2f04198 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -40,14 +40,16 @@
         return new Proxy(structuredClone(this.defaultData), Entry(entry)) as unknown as GuildConfig
     }
 
-    async write(guild: string, set: object = {}, unset: string[] = []) {
+    async write(guild: string, set: object | null, unset: string[] | string = []) {
         let uo = {}
+        if (!Array.isArray(unset)) unset = [unset]
         for (let key of unset) {
             uo[key] = null;
         }
-        let out = {}
+        let out = {$set: {}, $unset: {}}
         if (set) out["$set"] = set;
         if (unset.length) out["$unset"] = uo;
+        console.log(out)
         await this.guilds.updateOne({ id: guild }, out, { upsert: true });
     }
 
@@ -79,6 +81,10 @@
             }, { upsert: true });
         }
     }
+
+    async delete(guild: string) {
+        await this.guilds.deleteOne({ id: guild });
+    }
 }
 
 
@@ -116,6 +122,10 @@
         }).toArray()) as HistorySchema[];
         return entry;
     }
+
+    async delete(guild: string) {
+        await this.histories.deleteMany({ guild: guild });
+    }
 }
 
 export class ModNotes {
@@ -147,7 +157,7 @@
 
     async hasPremium(guild: string) {
         let entry = await this.premium.findOne({ appliesTo: { $in: [guild] } });
-        return entry != null;
+        return entry !== null;
     }
 }
 
diff --git a/src/utils/defaultEmbeds.ts b/src/utils/defaultEmbeds.ts
new file mode 100644
index 0000000..0f226da
--- /dev/null
+++ b/src/utils/defaultEmbeds.ts
@@ -0,0 +1,8 @@
+import EmojiEmbed from "./generateEmojiEmbed.js"
+
+export const LoadingEmbed = [new EmojiEmbed()
+    .setTitle("Loading")
+    .setDescription("One moment...")
+    .setStatus("Danger")
+    .setEmoji("NUCLEUS.LOADING")]
+
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 987e256..22da837 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -11,7 +11,7 @@
 
 export class Logger {
     renderUser(user: Discord.User | string) {
-        if (typeof user == 'string') return `${user} [<@${user}>]`;
+        if (typeof user === 'string') return `${user} [<@${user}>]`;
         return `${user.username} [<@${user.id}>]`;
     }
     renderTime(t: number) {
@@ -55,7 +55,7 @@
     async log(log: any): Promise<void> {
         let config = await client.database.guilds.read(log.hidden.guild);
         if (!config.logging.logs.enabled) return;
-        if (!(log.meta.calculateType == true)) {
+        if (!(log.meta.calculateType === true)) {
             if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log('Not logging this type of event');
         }
         if (config.logging.logs.channel) {
@@ -84,20 +84,8 @@
                 channel.send({embeds: [embed]});
             }
         }
-        saveLog(log);
     }
 }
 
 
 export default {}
-
-async function saveLog(log: any): Promise<void> {
-}
-
-export function readLogs(guild: string) {
-    
-}
-
-export function readSpecificLog(guild: string, id: number) {
-    
-}
diff --git a/src/utils/singleNotify.ts b/src/utils/singleNotify.ts
index 051ec4d..f29d775 100644
--- a/src/utils/singleNotify.ts
+++ b/src/utils/singleNotify.ts
@@ -7,11 +7,13 @@
     "Info": "Success"
 }
 
-export default async function(type: string, guild: string, message: string, severity: string) {
+export default async function(type: string, guild: string, message: string | true, severity?: string) {
     let data = await client.database.guilds.read(guild);
+    if (message === true) {
+        return await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: false});
+    }
     if (data.singleEventNotifications[type]) return;
-    data.singleEventNotifications[type] = true;
-    client.database.guilds.write(guild, data);
+    await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: true});
     try {
         let channel = await client.channels.fetch(data.logging.staff.channel);
         if (!channel) return;
