diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index d49633c..db43527 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
+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";
@@ -9,14 +9,14 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder // TODO: DON'T RELEASE THIS
-    .setName("all")
-    .setDescription("Gives or removes a role from everyone")
+        .setName("all")
+        .setDescription("Gives or removes a role from everyone");
 
 class Filter {
     name: string;
     data: object;
     checkFunction: (member) => boolean;
-    inverted: boolean = false;
+    inverted = false;
     constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
         if (typeof name === "function") { this.name = name(data);
         } else { this.name = name; }
@@ -25,8 +25,8 @@
     }
     flip() { this.inverted = true; return this; }
     check(member) {
-        if (this.inverted) return !this.checkFunction(member)
-        else return this.checkFunction(member)
+        if (this.inverted) return !this.checkFunction(member);
+        else return this.checkFunction(member);
     }
 }
 
@@ -35,23 +35,23 @@
         render: "Member",
         has: {
             render: "has",
-            role: (role) => ( new Filter((data) => `Member has role <@&${data.role}>`, {role: role, type: Discord.Role, render: "role"}, (member) => { return member.roles.cache.has(role)}))
+            role: (role) => ( new Filter((data) => `Member has role <@&${data.role}>`, {role: role, type: Discord.Role, render: "role"}, (member) => { return member.roles.cache.has(role);}))
         },
         joined: {
             render: "joined",
             before: (date) => ( new Filter((data) => `Joined server before <t:${Math.round(date.getTime() / 1000)}:D>`, {date: date, type: Date, render: "before"}, (member) => {
-                return member.joinedTimestamp < date.getTime()
+                return member.joinedTimestamp < date.getTime();
             }))
         },
         nickname: {
             render: "Nickname",
-            set: () => ( new Filter((data) => `Member has a nickname set"`, {render: "set"}, (member) => { return member.nickname !== null})),
+            set: () => ( new Filter((data) => "Member has a nickname set\"", {render: "set"}, (member) => { return member.nickname !== null;})),
             includes: (name) => ( new Filter((data) => `Nickname includes "${name}"`, {nickname: name, type: String, render: "includes"}, (member) => {
-                return member.displayName.includes(name)})),
+                return member.displayName.includes(name);})),
             startsWith: (name) => ( new Filter((data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
-                return member.displayName.startsWith(name)})),
+                return member.displayName.startsWith(name);})),
             endsWith: (name) => ( new Filter((data) => `Nickname ends with "${name}"`, {nickname: name, type: String, render: "ends with"}, (member) => {
-                return member.displayName.endsWith(name)}))
+                return member.displayName.endsWith(name);}))
         }
     },
     account: {
@@ -59,49 +59,49 @@
         created: {
             render: "created",
             before: (date) => ( new Filter((data) => `Account created before <t:${Math.round(date.getTime() / 1000)}:D>`, {date: date, type: Date, render: "before"}, (member) => {
-                return member.user.createdTimestamp < date.getTime()
+                return member.user.createdTimestamp < date.getTime();
             }))
         },
         is: {
             render: "is",
-            human: () => ( new Filter((data) => `Member is a human`, {human: true, render: "human"}, (member) => { return !member.bot })),
+            human: () => ( new Filter((data) => "Member is a human", {human: true, render: "human"}, (member) => { return !member.bot; }))
         },
         username: {
             render: "Username",
             includes: (name) => ( new Filter((data) => `Nickname includes "${name}"`, {nickname: name, type: String, render: "includes"}, (member) => {
-                return member.user.name.includes(name)})),
+                return member.user.name.includes(name);})),
             startsWith: (name) => ( new Filter((data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
-                return member.user.name.startsWith(name)})),
+                return member.user.name.startsWith(name);})),
             endsWith: (name) => ( new Filter((data) => `Nickname ends with "${name}"`, {nickname: name, type: String, render: "ends with"}, (member) => {
-                return member.user.name.endsWith(name)}))
+                return member.user.name.endsWith(name);}))
         }
     }
-}
+};
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
-    let filters: Filter[] = [
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+    const filters: Filter[] = [
         filterList.member.has.role("959901346000154674"),
         filterList.member.nickname.startsWith("Pinea"),
         filterList.member.joined.before(new Date(2022, 1)).flip()
-    ]
-    let all = true;
+    ];
+    const all = true;
     while (true) {
         let count = 0;
-        let affected = []
-        let members = interaction.guild.members.cache
+        const affected = [];
+        const members = interaction.guild.members.cache;
         if (all) {
             members.forEach(member => {
                 let applies = true;
-                filters.forEach(filter => { if (!filter.check(member)) { applies = false } })
-                if (applies) { affected.push(member) }
-            })
+                filters.forEach(filter => { if (!filter.check(member)) { applies = false; } });
+                if (applies) { affected.push(member); }
+            });
         } else {
             members.forEach(member => {
                 let applies = false;
-                filters.forEach(filter => { if (filter.check(member)) { applies = true } })
-                if (applies) { affected.push(member) }
-            })
+                filters.forEach(filter => { if (filter.check(member)) { applies = true; } });
+                if (applies) { affected.push(member); }
+            });
         }
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Role all")
@@ -109,7 +109,7 @@
                 filters.map((f) => {
                     count ++;
                     return (count === 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
-                        (f.inverted ? "**not** " : "") + `${f.name}`
+                        (f.inverted ? "**not** " : "") + `${f.name}`;
                 }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
             .setEmoji("GUILD.ROLES.CREATE")
             .setStatus("Success")
@@ -132,22 +132,22 @@
                     .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
                     .setDisabled(filters.length >= 25)
             ])
-        ]})
-        break
+        ]});
+        break;
     }
-}
+};
 
 const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as GuildMember)
-    let me = (interaction.guild.me as GuildMember)
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
     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";
     // Allow role
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
index c75d1bb..4d0d50a 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,22 +1,22 @@
-import { LoadingEmbed } from '../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "../utils/defaultEmbeds.js";
 import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
 import { SlashCommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import client from "../utils/client.js"
+import client from "../utils/client.js";
 import addPlural from "../utils/plurals.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 
 const command = new SlashCommandBuilder()
     .setName("categorise")
-    .setDescription("Categorises your servers channels")
+    .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 = {}
+    const channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
+    const categorised = {};
     await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
-    let predicted = {}
-    let types = {
+    const predicted = {};
+    const types = {
         general: ["general", "muted", "main", "topic", "discuss"],
         commands: ["bot", "command", "music"],
         images: ["pic", "selfies", "image"],
@@ -26,25 +26,25 @@
         staff: ["staff", "mod", "admin"],
         spam: ["spam"],
         other: ["random"]
-    }
-    for (let c of channels.values()) {
-        for (let type in types) {
-            for (let word of types[type]) {
+    };
+    for (const c of channels.values()) {
+        for (const type in types) {
+            for (const word of types[type]) {
                 if (c.name.toLowerCase().includes(word)) {
-                    predicted[c.id] = predicted[c.id] ?? []
-                    predicted[c.id].push(type)
+                    predicted[c.id] = predicted[c.id] ?? [];
+                    predicted[c.id].push(type);
                 }
             }
         }
     }
     let m;
-    for (let c of channels) {
+    for (const c of channels) {
         // convert channel to a channel if its a string
-        let channel: any
-        if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel).id
-        else channel = (c[0] as unknown as GuildChannel).id
-        console.log(channel)
-        if (!predicted[channel]) predicted[channel] = []
+        let channel: any;
+        if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel).id;
+        else channel = (c[0] as unknown as GuildChannel).id;
+        console.log(channel);
+        if (!predicted[channel]) predicted[channel] = [];
         m = await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Categorise")
             .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
@@ -65,7 +65,7 @@
                 new MessageButton().setLabel("Use \"Other\"").setCustomId("reject").setStyle("SECONDARY")
                     .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
             ])
-        ]})
+        ]});
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
@@ -77,21 +77,21 @@
                 .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
                 `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
                 .setFooter({text: "Message timed out"})
-            ]})
+            ]});
         }
-        i.deferUpdate()
+        i.deferUpdate();
         let selected;
         if (i.customId === "select") { selected = i.values; }
         if (i.customId === "accept") { selected = predicted[channel]; }
         if (i.customId === "reject") { selected = ["other"]; }
-        categorised[channel] = selected
+        categorised[channel] = selected;
     }
-    console.log(categorised)
-}
+    console.log(categorised);
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/actions/createModActionTicket.ts b/src/actions/createModActionTicket.ts
index 7bd3d22..1d3406d 100644
--- a/src/actions/createModActionTicket.ts
+++ b/src/actions/createModActionTicket.ts
@@ -1,12 +1,12 @@
-import Discord, { MessageActionRow, MessageButton } from 'discord.js';
-import EmojiEmbed from '../utils/generateEmojiEmbed.js';
+import Discord, { MessageActionRow, MessageButton } from "discord.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 import client from "../utils/client.js";
 
 export async function create(guild: Discord.Guild, member: Discord.User, createdBy: Discord.User, reason: string, customReason?: string) {
-    let config = await client.database.guilds.read(guild.id);
-    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
-    let overwrites = [{
+    const config = await client.database.guilds.read(guild.id);
+    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+    const overwrites = [{
         id: member,
         allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
         type: "member"
@@ -15,13 +15,13 @@
         id: guild.roles.everyone,
         deny: ["VIEW_CHANNEL"],
         type: "role"
-    })
+    });
     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"],
             type: "role"
-        })
+        });
     }
 
     let c;
@@ -33,9 +33,9 @@
             nsfw: false,
             permissionOverwrites: (overwrites as Discord.OverwriteResolvable[]),
             reason: "Creating ticket"
-        })
+        });
     } catch (e) {
-        return null
+        return null;
     }
     try {
         await c.send(
@@ -46,14 +46,14 @@
                     roles: (config.tickets.supportRole !== null ? [config.tickets.supportRole] : [])
                 }
             }
-        )
+        );
         await c.send({ embeds: [new EmojiEmbed()
             .setTitle("New Ticket")
             .setDescription(
-                `Ticket created by a Moderator\n` +
+                "Ticket created by a Moderator\n" +
                 `**Support type:** ${customReason ? customReason : "Appeal submission"}\n` + (reason !== null ? `**Reason:**\n> ${reason}\n` : "") +
                 `**Ticket ID:** \`${c.id}\`\n` +
-                `Type \`/ticket close\` to close this ticket.`,
+                "Type `/ticket close` to close this ticket."
             )
             .setStatus("Success")
             .setEmoji("GUILD.TICKET.OPEN")
@@ -62,32 +62,32 @@
             .setStyle("DANGER")
             .setCustomId("closeticket")
             .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-        ])]})
-        let data = {
+        ])]});
+        const data = {
             meta:{
-                type: 'ticketCreate',
-                displayName: 'Ticket Created',
+                type: "ticketCreate",
+                displayName: "Ticket Created",
                 calculateType: "ticketUpdate",
                 color: NucleusColors.green,
-                emoji: 'GUILD.TICKET.OPEN',
+                emoji: "GUILD.TICKET.OPEN",
                 timestamp: new Date().getTime()
             },
             list: {
                 ticketFor: entry(member.id, renderUser(member)),
                 createdBy: entry(createdBy.id, renderUser(createdBy)),
                 created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                ticketChannel: entry(c.id, renderChannel(c)),
+                ticketChannel: entry(c.id, renderChannel(c))
             },
             hidden: {
                 guild: guild.id
             }
-        }
+        };
         log(data);
-    } catch (e) { console.log(e); return null }
-    return c.id
+    } catch (e) { console.log(e); return null; }
+    return c.id;
 }
 
 export async function areTicketsEnabled(guild: string) {
-    let config = await client.database.guilds.read(guild);
+    const config = await client.database.guilds.read(guild);
     return config.tickets.enabled;
 }
\ No newline at end of file
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index 21e97ec..6fd73ac 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -1,42 +1,43 @@
 import { Message, MessageButton } from "discord.js";
-import EmojiEmbed from '../utils/generateEmojiEmbed.js'
-import { MessageActionRow, MessageSelectMenu } from 'discord.js';
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
+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);
+    const config = await client.database.guilds.read(interaction.guild.id);
     if (!config.roleMenu.enabled) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Roles")
         .setDescription("Self roles are currently disabled. Please contact a staff member or try again later.")
         .setStatus("Danger")
         .setEmoji("CONTROL.BLOCKCROSS")
-    ], ephemeral: true})
+    ], ephemeral: true});
     if (config.roleMenu.options.length === 0) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Roles")
         .setDescription("There are no roles available. Please contact a staff member or try again later.")
         .setStatus("Danger")
         .setEmoji("CONTROL.BLOCKCROSS")
-    ], ephemeral: true})
-    await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
+    ], ephemeral: true});
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
     let m;
     if (config.roleMenu.allowWebUI) {
-        let code = ""
-        let length = 5
-        let itt = 0
+        let code = "";
+        let length = 5;
+        let itt = 0;
         const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-        while (true) {
-            itt += 1
-            code = ""
+        let valid = false;
+        while (!valid) {
+            itt += 1;
+            code = "";
             for (let i = 0; i < length; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); }
             if (code in client.roleMenu) continue;
             if (itt > 1000) {
-                itt = 0
-                length += 1
+                itt = 0;
+                length += 1;
                 continue;
             }
-            break;
+            valid = true;
         }
         client.roleMenu[code] = {
             guild: interaction.guild.id,
@@ -47,11 +48,11 @@
             data: config.roleMenu.options,
             interaction: interaction
         };
-        let up = true
+        let up = true;
         try {
-            let status = await fetch(client.config.baseUrl).then(res => res.status);
-            if (status !== 200) up = false
-        } catch { up = false }
+            const status = await fetch(client.config.baseUrl).then(res => res.status);
+            if (status !== 200) up = false;
+        } catch { up = false; }
         m = await interaction.editReply({
             embeds: [new EmojiEmbed()
                 .setTitle("Roles")
@@ -69,22 +70,22 @@
                     .setStyle("PRIMARY")
                     .setCustomId("manual")
             ])]
-        })
+        });
     }
     let component;
     try { component = await (m as Message).awaitMessageComponent({time: 300000});
-    } catch (e) { return }
-    component.deferUpdate()
-    let rolesToAdd = []
+    } catch (e) { return; }
+    component.deferUpdate();
+    let rolesToAdd = [];
     for (let i = 0; i < config.roleMenu.options.length; i++) {
-        let object = config.roleMenu.options[i];
-        let m = await interaction.editReply({
+        const object = config.roleMenu.options[i];
+        const m = await interaction.editReply({
             embeds: [
                 new EmojiEmbed()
                     .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.`)
+                    .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.`)
                     .setStatus("Success")
                     .setFooter({text: `Step ${i + 1}/${config.roleMenu.options.length}`})
             ],
@@ -95,59 +96,59 @@
                         .setStyle("DANGER")
                         .setCustomId("cancel")
                         .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                    ].concat(object.min === 0 ? [
-                        new MessageButton()
-                            .setLabel("Skip")
-                            .setStyle("SECONDARY")
-                            .setCustomId("skip")
-                            .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
-                        ] : []))
+                ].concat(object.min === 0 ? [
+                    new MessageButton()
+                        .setLabel("Skip")
+                        .setStyle("SECONDARY")
+                        .setCustomId("skip")
+                        .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+                ] : []))
             ].concat([new MessageActionRow().addComponents([new MessageSelectMenu()
                 .setPlaceholder(`${object.name}`)
                 .setCustomId("rolemenu")
                 .setMinValues(object.min)
                 .setMaxValues(object.max)
-                .setOptions(object.options.map(o => { return {label: o.name, description: o.description, value: o.role} }))
+                .setOptions(object.options.map(o => { return {label: o.name, description: o.description, value: o.role}; }))
             ])])
         });
         let component;
         try {
             component = await (m as Message).awaitMessageComponent({time: 300000});
         } catch (e) {
-            return
+            return;
         }
-        component.deferUpdate()
+        component.deferUpdate();
         if (component.customId === "rolemenu") {
-            rolesToAdd = rolesToAdd.concat(component.values)
+            rolesToAdd = rolesToAdd.concat(component.values);
         } else if (component.customId === "cancel") {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Roles")
                 .setDescription("Cancelled. No changes were made.")
                 .setStatus("Danger")
                 .setEmoji("GUILD.RED")
-            ], components: []})
+            ], components: []});
         }
     }
-    let rolesToRemove = config.roleMenu.options.map(o => o.options.map(o => o.role)).flat()
-    let memberRoles = interaction.member.roles.cache.map(r => r.id)
-    rolesToRemove = rolesToRemove.filter(r => memberRoles.includes(r)).filter(r => !rolesToAdd.includes(r))
-    rolesToAdd = rolesToAdd.filter(r => !memberRoles.includes(r))
+    let rolesToRemove = config.roleMenu.options.map(o => o.options.map(o => o.role)).flat();
+    const memberRoles = interaction.member.roles.cache.map(r => r.id);
+    rolesToRemove = rolesToRemove.filter(r => memberRoles.includes(r)).filter(r => !rolesToAdd.includes(r));
+    rolesToAdd = rolesToAdd.filter(r => !memberRoles.includes(r));
     try {
-        await interaction.member.roles.remove(rolesToRemove)
-        await interaction.member.roles.add(rolesToAdd)
+        await interaction.member.roles.remove(rolesToRemove);
+        await interaction.member.roles.add(rolesToAdd);
     } catch (e) {
         return await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Roles")
             .setDescription("Something went wrong and your roles were not added. Please contact a staff member or try again later.")
             .setStatus("Danger")
             .setEmoji("GUILD.RED")
-        ], components: []})
+        ], components: []});
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Roles")
         .setDescription("Roles have been added. You may close this message.")
         .setStatus("Success")
         .setEmoji("GUILD.GREEN")
-    ], components: []})
-    return
+    ], components: []});
+    return;
 }
diff --git a/src/actions/tickets/create.ts b/src/actions/tickets/create.ts
index 28eb435..6c8d42c 100644
--- a/src/actions/tickets/create.ts
+++ b/src/actions/tickets/create.ts
@@ -5,14 +5,14 @@
 import getEmojiByName from "../../utils/getEmojiByName.js";
 
 function capitalize(s: string) {
-    s = s.replace(/([A-Z])/g, ' $1');
+    s = s.replace(/([A-Z])/g, " $1");
     return s.length < 3 ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase();
 }
 
 export default async function (interaction) {
-    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
+    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
 
-    let config = await client.database.guilds.read(interaction.guild.id);
+    const config = await client.database.guilds.read(interaction.guild.id);
     if (!config.tickets.enabled || !config.tickets.category) {
         return await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Tickets are disabled")
@@ -22,7 +22,7 @@
             .setEmoji("CONTROL.BLOCKCROSS")
         ], ephemeral: true});
     }
-    let category = interaction.guild.channels.cache.get(config.tickets.category) as Discord.CategoryChannel;
+    const 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;
@@ -41,8 +41,8 @@
         ], ephemeral: true});
     }
     let ticketTypes;
-    let custom = false
-    if (config.tickets.customTypes && config.tickets.useCustom) { ticketTypes = config.tickets.customTypes; custom = true }
+    let custom = false;
+    if (config.tickets.customTypes && config.tickets.useCustom) { ticketTypes = config.tickets.customTypes; custom = true; }
     else if (config.tickets.types) ticketTypes = toHexArray(config.tickets.types, tickets);
     else ticketTypes = [];
     let chosenType;
@@ -54,7 +54,7 @@
                 return new MessageButton()
                     .setLabel(type)
                     .setStyle("PRIMARY")
-                    .setCustomId(type)
+                    .setCustomId(type);
             } else {
                 return new MessageButton()
                     .setLabel(capitalize(type))
@@ -66,7 +66,7 @@
         for (let i = 0; i < formattedTicketTypes.length; i += 5) {
             splitFormattedTicketTypes.push(new MessageActionRow().addComponents(formattedTicketTypes.slice(i, i + 5)));
         }
-        let m = await interaction.reply({embeds: [new EmojiEmbed()
+        const m = await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Create Ticket")
             .setDescription("Select a ticket type")
             .setStatus("Success")
@@ -87,14 +87,14 @@
                     .setLabel(type)
                     .setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
                     .setCustomId(type)
-                    .setDisabled(true)
-                } else {
-                    return new MessageButton()
+                    .setDisabled(true);
+            } else {
+                return new MessageButton()
                     .setLabel(capitalize(type))
                     .setStyle(chosenType === type ? "SUCCESS" : "SECONDARY")
                     .setCustomId(type)
                     .setEmoji(getEmojiByName(("TICKETS." + type.toString().toUpperCase()), "id"))
-                    .setDisabled(true)
+                    .setDisabled(true);
             }
         });
         for (let i = 0; i < formattedTicketTypes.length; i += 5) {
@@ -107,13 +107,13 @@
             .setEmoji("GUILD.TICKET.OPEN")
         ], components: splitFormattedTicketTypes});
     } else {
-        chosenType = null
+        chosenType = null;
         await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Create Ticket")
             .setEmoji("GUILD.TICKET.OPEN")
-        ], ephemeral: true, components: splitFormattedTicketTypes})
+        ], ephemeral: true, components: splitFormattedTicketTypes});
     }
-    let overwrites = [{
+    const overwrites = [{
         id: interaction.member,
         allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
         type: "member"
@@ -122,13 +122,13 @@
         id: interaction.guild.roles.everyone,
         deny: ["VIEW_CHANNEL"],
         type: "role"
-    })
+    });
     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"],
             type: "role"
-        })
+        });
     }
 
     let c;
@@ -140,7 +140,7 @@
             nsfw: false,
             permissionOverwrites: (overwrites as Discord.OverwriteResolvable[]),
             reason: "Creating ticket"
-        })
+        });
     } catch (e) {
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Create Ticket")
@@ -158,17 +158,17 @@
                     roles: (config.tickets.supportRole !== null ? [config.tickets.supportRole] : [])
                 }
             }
-        )
+        );
         let content = interaction.options ? interaction.options.getString("message") || "" : "";
         if (content) content = `**Message:**\n> ${content}\n`;
-        let emoji = custom ? "" : getEmojiByName("TICKETS." + chosenType.toUpperCase());
+        const emoji = custom ? "" : getEmojiByName("TICKETS." + chosenType.toUpperCase());
         await c.send({ embeds: [new EmojiEmbed()
             .setTitle("New Ticket")
             .setDescription(
                 `Ticket created by <@${interaction.member.user.id}>\n` +
                 `**Support type:** ${chosenType !== null ? (emoji) + " " + capitalize(chosenType) : "General"}\n` +
                 `**Ticket ID:** \`${c.id}\`\n${content}\n` +
-                `Type \`/ticket close\` to close this ticket.`,
+                "Type `/ticket close` to close this ticket."
             )
             .setStatus("Success")
             .setEmoji("GUILD.TICKET.OPEN")
@@ -177,27 +177,27 @@
             .setStyle("DANGER")
             .setCustomId("closeticket")
             .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-        ])]})
-        let data = {
+        ])]});
+        const data = {
             meta:{
-                type: 'ticketCreate',
-                displayName: 'Ticket Created',
+                type: "ticketCreate",
+                displayName: "Ticket Created",
                 calculateType: "ticketUpdate",
                 color: NucleusColors.green,
-                emoji: 'GUILD.TICKET.OPEN',
+                emoji: "GUILD.TICKET.OPEN",
                 timestamp: new Date().getTime()
             },
             list: {
                 ticketFor: entry(interaction.member.user.id, renderUser(interaction.member.user)),
                 created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                ticketChannel: entry(c.id, renderChannel(c)),
+                ticketChannel: entry(c.id, renderChannel(c))
             },
             hidden: {
                 guild: interaction.guild.id
             }
-        }
+        };
         log(data);
-    } catch (e) { console.log(e)}
+    } catch (e) { console.log(e);}
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Create Ticket")
         .setDescription(`Ticket created. You can view it here: <#${c.id}>`)
diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index d86396a..3419763 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -4,12 +4,12 @@
 import getEmojiByName from "../../utils/getEmojiByName.js";
 
 export default async function (interaction) {
-    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
+    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
 
-    let config = await client.database.guilds.read(interaction.guild.id);
-    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)
+    const config = await client.database.guilds.read(interaction.guild.id);
+    let thread = false; let threadChannel;
+    if (interaction.channel instanceof Discord.ThreadChannel) thread = true; threadChannel = interaction.channel as Discord.ThreadChannel;
+    const channel = (interaction.channel as Discord.TextChannel);
     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...")
@@ -18,7 +18,7 @@
             .setEmoji("CONTROL.BLOCKCROSS")
         ], ephemeral: true});
     }
-    let status = channel.topic.split(" ")[1];
+    const status = channel.topic.split(" ")[1];
     if (status === "Archived") {
         await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Delete Ticket")
@@ -26,13 +26,13 @@
             .setStatus("Danger")
             .setEmoji("GUILD.TICKET.CLOSE")
         ]});
-        let data = {
+        const data = {
             meta:{
-                type: 'ticketDeleted',
-                displayName: 'Ticket Deleted',
+                type: "ticketDeleted",
+                displayName: "Ticket Deleted",
                 calculateType: "ticketUpdate",
                 color: NucleusColors.red,
-                emoji: 'GUILD.TICKET.CLOSE',
+                emoji: "GUILD.TICKET.CLOSE",
                 timestamp: new Date().getTime()
             },
             list: {
@@ -43,7 +43,7 @@
             hidden: {
                 guild: interaction.guild.id
             }
-        }
+        };
         log(data);
         interaction.channel.delete();
         return;
@@ -54,7 +54,7 @@
             .setStatus("Warning")
             .setEmoji("GUILD.TICKET.ARCHIVED")
         ]});
-        let overwrites = [
+        const overwrites = [
             {
                 id: channel.topic.split(" ")[0],
                 deny: ["VIEW_CHANNEL"],
@@ -71,29 +71,29 @@
                 id: interaction.guild.roles.cache.get(config.tickets.supportRole),
                 allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
                 type: "role"
-            })
+            });
         }
-        channel.edit({permissionOverwrites: overwrites})
+        channel.edit({permissionOverwrites: overwrites});
         channel.setTopic(`${channel.topic.split(" ")[0]} Archived`);
-        let data = {
+        const data = {
             meta:{
-                type: 'ticketClosed',
-                displayName: 'Ticket Closed',
+                type: "ticketClosed",
+                displayName: "Ticket Closed",
                 calculateType: "ticketUpdate",
                 color: NucleusColors.yellow,
-                emoji: 'GUILD.TICKET.ARCHIVED',
+                emoji: "GUILD.TICKET.ARCHIVED",
                 timestamp: new Date().getTime()
             },
             list: {
                 ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
                 closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
                 closed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                ticketChannel: entry(channel.id, renderChannel(channel)),
+                ticketChannel: entry(channel.id, renderChannel(channel))
             },
             hidden: {
                 guild: interaction.guild.id
             }
-        }
+        };
         log(data);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Close Ticket")
@@ -107,8 +107,8 @@
                     .setStyle("DANGER")
                     .setCustomId("closeticket")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-                ].concat(client.database.premium.hasPremium(interaction.guild.id) ? [
-                    new MessageButton()
+            ].concat(client.database.premium.hasPremium(interaction.guild.id) ? [
+                new MessageButton()
                     .setLabel("Create Transcript and Delete")
                     .setStyle("PRIMARY")
                     .setCustomId("createtranscript")
@@ -120,42 +120,44 @@
 }
 
 async function purgeByUser(member, guild) {
-    let config = await client.database.guilds.read(guild.id);
+    const config = await client.database.guilds.read(guild.id);
     if (!config.tickets.category) return;
-    let tickets = guild.channels.cache.get(config.tickets.category);
+    const tickets = guild.channels.cache.get(config.tickets.category);
     if (!tickets) return;
-    let ticketChannels = tickets.children;
-    let deleted = 0
+    const ticketChannels = tickets.children;
+    let deleted = 0;
     ticketChannels.forEach(element => {
         if (element.type !== "GUILD_TEXT") return;
         if (element.topic.split(" ")[0] === member) {
-            try { element.delete(); } catch {}
-            deleted++
+            try {
+                element.delete();
+            } catch { /* Errors if the channel does not exist (deleted already) */ }
+            deleted++;
         }
     });
     if (deleted) {
-        const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
-        let data = {
+        const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+        const data = {
             meta:{
-                type: 'ticketPurge',
-                displayName: 'Tickets Purged',
+                type: "ticketPurge",
+                displayName: "Tickets Purged",
                 calculateType: "ticketUpdate",
                 color: NucleusColors.red,
-                emoji: 'GUILD.TICKET.DELETE',
+                emoji: "GUILD.TICKET.DELETE",
                 timestamp: new Date().getTime()
             },
             list: {
                 ticketFor: entry(member, renderUser(member)),
                 deletedBy: entry(null, "Member left server"),
                 deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                ticketsDeleted: deleted,
+                ticketsDeleted: deleted
             },
             hidden: {
                 guild: guild.id
             }
-        }
+        };
         log(data);
     }
 }
 
-export { purgeByUser }
\ No newline at end of file
+export { purgeByUser };
\ No newline at end of file
diff --git a/src/api/index.ts b/src/api/index.ts
index 5cc4a99..1750509 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,9 +1,9 @@
-import { HaikuClient } from 'jshaiku';
-import express from 'express';
-import bodyParser from 'body-parser';
+import type { HaikuClient } from "jshaiku";
+import express from "express";
+import bodyParser from "body-parser";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import structuredClone from '@ungap/structured-clone';
-import client from '../utils/client.js';
+import structuredClone from "@ungap/structured-clone";
+import client from "../utils/client.js";
 
 
 const jsonParser = bodyParser.json();
@@ -11,38 +11,38 @@
 const port = 10000;
 
 const runServer = (client: HaikuClient) => {
-    app.get('/', (req, res) => {
+    app.get("/", (req, res) => {
         res.status(200).send(client.ws.ping);
     });
 
-    app.post('/verify/:code', jsonParser, async function (req, res) {
+    app.post("/verify/:code", jsonParser, async function (req, res) {
         const code = req.params.code;
         const secret = req.body.secret;
         if (secret === client.config.verifySecret) {
-            let guild = await client.guilds.fetch(client.verify[code].gID);
-            if (!guild) { return res.status(404) }
-            let member = await guild.members.fetch(client.verify[code].uID);
-            if (!member) { return res.status(404) }
-            if (member.roles.cache.has(client.verify[code].rID)) { return res.status(200) }
+            const guild = await client.guilds.fetch(client.verify[code].gID);
+            if (!guild) { return res.status(404); }
+            const member = await guild.members.fetch(client.verify[code].uID);
+            if (!member) { return res.status(404); }
+            if (member.roles.cache.has(client.verify[code].rID)) { return res.status(200); }
             await member.roles.add(client.verify[code].rID);
 
-            let interaction = client.verify[code].interaction;
+            const interaction = client.verify[code].interaction;
             if (interaction) {
                 interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Verify")
-                    .setDescription(`Verification complete`)
+                    .setDescription("Verification complete")
                     .setStatus("Success")
                     .setEmoji("MEMBER.JOIN")
                 ], components: []});
             }
             delete client.verify[code];
-            const { log, NucleusColors, entry, renderUser } = client.logger
+            const { log, NucleusColors, entry, renderUser } = client.logger;
             try {
-                let data = {
+                const data = {
                     meta:{
-                        type: 'memberVerify',
-                        displayName: 'Member Verified',
-                        calculateType: 'guildMemberVerify',
+                        type: "memberVerify",
+                        displayName: "Member Verified",
+                        calculateType: "guildMemberVerify",
                         color: NucleusColors.green,
                         emoji: "CONTROL.BLOCKTICK",
                         timestamp: new Date().getTime()
@@ -54,74 +54,76 @@
                     hidden: {
                         guild: guild.id
                     }
-                }
+                };
                 log(data);
-            } catch {}
+            } catch {
+                res.sendStatus(500);
+            }
             res.sendStatus(200);
         } else {
             res.sendStatus(403);
         }
     });
 
-    app.get('/verify/:code', jsonParser, function (req, res) {
+    app.get("/verify/:code", jsonParser, function (req, res) {
         const code = req.params.code;
         if (client.verify[code]) {
             try {
-                let interaction = client.verify[code].interaction;
+                const interaction = client.verify[code].interaction;
                 if (interaction) {
                     interaction.editReply({embeds: [new EmojiEmbed()
                         .setTitle("Verify")
-                        .setDescription(`Verify was opened in another tab or window, please complete the CAPTCHA there to continue`)
+                        .setDescription("Verify was opened in another tab or window, please complete the CAPTCHA there to continue")
                         .setStatus("Success")
                         .setEmoji("MEMBER.JOIN")
                     ]});
                 }
-            } catch {}
-            let data = structuredClone(client.verify[code])
+            } catch { return res.sendStatus(410); }
+            const data = structuredClone(client.verify[code]);
             delete data.interaction;
             return res.status(200).send(data);
         }
         return res.sendStatus(404);
-    })
+    });
 
-    app.post('/rolemenu/:code', jsonParser, async function (req, res) {
+    app.post("/rolemenu/:code", jsonParser, async function (req, res) {
         const code = req.params.code;
         const secret = req.body.secret;
         const data = req.body.data;
         if (secret === client.config.verifySecret) {
-            let guild = await client.guilds.fetch(client.roleMenu[code].guild);
-            if (!guild) { return res.status(404) }
-            let member = await guild.members.fetch(client.roleMenu[code].user);
-            if (!member) { return res.status(404) }
+            const guild = await client.guilds.fetch(client.roleMenu[code].guild);
+            if (!guild) { return res.status(404); }
+            const member = await guild.members.fetch(client.roleMenu[code].user);
+            if (!member) { return res.status(404); }
             res.sendStatus(200);
         } else {
             res.sendStatus(403);
         }
     });
 
-    app.get('/rolemenu/:code', jsonParser, function (req, res) {
+    app.get("/rolemenu/:code", jsonParser, function (req, res) {
         const code = req.params.code;
         if (client.roleMenu[code] !== undefined) {
             try {
-                let interaction = client.roleMenu[code].interaction;
+                const interaction = client.roleMenu[code].interaction;
                 if (interaction) {
                     interaction.editReply({embeds: [new EmojiEmbed()
                         .setTitle("Roles")
-                        .setDescription(`The role menu was opened in another tab or window, please select your roles there to continue`)
+                        .setDescription("The role menu was opened in another tab or window, please select your roles there to continue")
                         .setStatus("Success")
                         .setEmoji("GUILD.GREEN")
                     ], components: []});
                 }
-            } catch {}
-            let data = structuredClone(client.roleMenu[code])
+            } catch { return res.sendStatus(410); }
+            const data = structuredClone(client.roleMenu[code]);
             delete data.interaction;
-            console.log(data)
+            console.log(data);
             return res.status(200).send(data);
         }
         return res.sendStatus(404);
-    })
+    });
 
     app.listen(port);
-}
+};
 
 export default runServer;
\ No newline at end of file
diff --git a/src/commands/help.ts b/src/commands/help.ts
index c3b015c..900f24c 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -4,15 +4,15 @@
 
 const command = new SlashCommandBuilder()
     .setName("help")
-    .setDescription("Shows help for commands")
+    .setDescription("Shows help for commands");
 
-const callback = async (interaction: CommandInteraction): Promise<any> => {
+const callback = async (interaction: CommandInteraction): Promise<void> => {
     interaction.reply("hel p"); // TODO: FINISH THIS FOR RELEASE
-}
+};
 
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 8fc98d2..57db408 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -9,15 +9,15 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("ban")
-    .setDescription("Bans a user from the server")
-    .addUserOption(option => option.setName("user").setDescription("The user to ban").setRequired(true))
-    .addNumberOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false))
+        .setName("ban")
+        .setDescription("Bans a user from the server")
+        .addUserOption(option => option.setName("user").setDescription("The user to ban").setRequired(true))
+        .addNumberOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser } = client.logger
+    const { renderUser } = client.logger;
     // TODO:[Modals] Replace this with a modal
-    let reason = null
+    let reason = null;
     let notify = true;
     let confirmation;
     while (true) {
@@ -28,22 +28,22 @@
                 "user": renderUser(interaction.options.getUser("user")),
                 "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
             })
-            + `The user **will${notify ? '' : ' not'}** be notified\n`
+            + `The user **will${notify ? "" : " not"}** be notified\n`
             + `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
             + `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
             .setColor("Danger")
             .addReasonButton(reason ?? "")
-            .send(reason !== null)
-        reason = reason ?? ""
-        if (confirmation.cancelled) return
-        if (confirmation.success) break
-        if (confirmation.newReason) reason = confirmation.newReason
-        if (confirmation.components) notify = confirmation.components.notify.active
+            .send(reason !== null);
+        reason = reason ?? "";
+        if (confirmation.cancelled) return;
+        if (confirmation.success) break;
+        if (confirmation.newReason) reason = confirmation.newReason;
+        if (confirmation.components) notify = confirmation.components.notify.active;
     }
     if (confirmation.success) {
-        let dmd = false
+        let dmd = false;
         let dm;
-        let config = await client.database.guilds.read(interaction.guild.id);
+        const config = await client.database.guilds.read(interaction.guild.id);
         try {
             if (notify) {
                 dm = await (interaction.options.getMember("user") as GuildMember).send({
@@ -59,23 +59,23 @@
                         .setLabel(config.moderation.ban.text)
                         .setURL(config.moderation.ban.link)
                     ] : [])]
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
+        } catch { dmd = false; }
         try {
-            let member = (interaction.options.getMember("user") as GuildMember)
+            const member = (interaction.options.getMember("user") as GuildMember);
             member.ban({
                 days: Number(interaction.options.getNumber("delete") ?? 0),
                 reason: reason ?? "No reason provided"
-            })
-            try { await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason) } catch {}
-            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
-            let data = {
+            });
+            await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason);
+            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+            const data = {
                 meta: {
-                    type: 'memberBan',
-                    displayName: 'Member Banned',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberBan",
+                    displayName: "Member Banned",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.red,
                     emoji: "PUNISH.BAN.RED",
                     timestamp: new Date().getTime()
@@ -87,64 +87,64 @@
                     bannedBy: entry(interaction.user.id, renderUser(interaction.user)),
                     reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
                     accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                    serverMemberCount: interaction.guild.memberCount,
+                    serverMemberCount: interaction.guild.memberCount
                 },
                 hidden: {
                     guild: interaction.guild.id
                 }
-            }
+            };
             log(data);
         } catch {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.BAN.RED")
-                .setTitle(`Ban`)
+                .setTitle("Ban")
                 .setDescription("Something went wrong and the user was not banned")
                 .setStatus("Danger")
-            ], components: []})
-            if (dmd) await dm.delete()
-            return
+            ], components: []});
+            if (dmd) await dm.delete();
+            return;
         }
-        let failed = (dmd === false && notify)
+        const failed = (dmd === false && notify);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
-            .setTitle(`Ban`)
+            .setTitle("Ban")
             .setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
             .setStatus(failed ? "Warning" : "Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.BAN.GREEN")
-            .setTitle(`Ban`)
+            .setTitle("Ban")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow banning the owner
-    if (member.id === interaction.guild.ownerId) throw "You cannot ban the owner of the server"
+    if (member.id === interaction.guild.ownerId) throw "You cannot ban the owner of the server";
     // Check if Nucleus can ban the member
-    if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+    if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to ban
     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";
     // Check if the user is below on the role list
-    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow ban
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index c50c6f4..482af5b 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -1,18 +1,18 @@
-import { HistorySchema } from '../../utils/database';
+import { HistorySchema } from "../../utils/database";
 import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, TextInputComponent } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import client from "../../utils/client.js";
-import { modalInteractionCollector } from '../../utils/dualCollector.js';
-import pageIndicator from '../../utils/createPageIndicator.js';
+import { modalInteractionCollector } from "../../utils/dualCollector.js";
+import pageIndicator from "../../utils/createPageIndicator.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("info")
-    .setDescription("Shows moderator information about a user")
-    .addUserOption(option => option.setName("user").setDescription("The user to get information about").setRequired(true))
+        .setName("info")
+        .setDescription("Shows moderator information about a user")
+        .addUserOption(option => option.setName("user").setDescription("The user to get information about").setRequired(true));
 
 const types = {
     "warn": {emoji: "PUNISH.WARN.YELLOW", text: "Warned"},
@@ -26,7 +26,7 @@
     "unban": {emoji: "MEMBER.UNBAN", text: "Unbanned"},
     "purge": {emoji: "PUNISH.CLEARHISTORY", text: "Messages cleared"},
     "nickname": {emoji: "PUNISH.NICKNAME.YELLOW", text: "Nickname changed"}
-}
+};
 
 function historyToString(history: HistorySchema) {
     let s = `${getEmojiByName(types[history.type].emoji)} ${
@@ -44,16 +44,16 @@
 
 class TimelineSection {
     name: string;
-    content: {data: HistorySchema, rendered: string}[] = []
+    content: {data: HistorySchema, rendered: string}[] = [];
 
-    addContent = (content: {data: HistorySchema, rendered: string}) => { this.content.push(content); return this; }
+    addContent = (content: {data: HistorySchema, rendered: string}) => { this.content.push(content); return this; };
     contentLength = () => { return this.content.reduce((acc, cur) => acc + cur.rendered.length, 0); };
     generateName = () => {
-        let first = Math.round(this.content[0].data.occurredAt.getTime() / 1000)
-        let last = Math.round(this.content[this.content.length - 1].data.occurredAt.getTime() / 1000)
+        const first = Math.round(this.content[0].data.occurredAt.getTime() / 1000);
+        const last = Math.round(this.content[this.content.length - 1].data.occurredAt.getTime() / 1000);
         if (first === last) { return this.name = `<t:${first}:F>`; }
         return this.name = `<t:${first}:F> - <t:${last}:F>`;
-    }
+    };
 }
 
 const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
@@ -70,15 +70,15 @@
             history = await client.database.history.read(member.guild.id, member.id, currentYear);
             history = history.sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime()).reverse();
             if (openFilterPane) {
-                let tempFilteredTypes = filteredTypes
+                let tempFilteredTypes = filteredTypes;
                 if (filteredTypes.length === 0) { tempFilteredTypes = Object.keys(types); }
-                history = history.filter(h => tempFilteredTypes.includes(h.type))
-            };
+                history = history.filter(h => tempFilteredTypes.includes(h.type));
+            }
             refresh = false;
         }
-        let groups: TimelineSection[] = []
+        const groups: TimelineSection[] = [];
         if (history.length > 0) {
-            current = new TimelineSection()
+            current = new TimelineSection();
             history.forEach(event => {
                 if (current.contentLength() + historyToString(event).length > 2000 || current.content.length === 5) {
                     groups.push(current);
@@ -91,17 +91,17 @@
             groups.push(current);
             if (pageIndex === null) { pageIndex = groups.length - 1; }
         }
-        let components = (
+        const components = (
             openFilterPane ? [
-            new MessageActionRow().addComponents([new Discord.MessageSelectMenu().setOptions(
-                Object.entries(types).map(([key, value]) => ({
+                new MessageActionRow().addComponents([new Discord.MessageSelectMenu().setOptions(
+                    Object.entries(types).map(([key, value]) => ({
                         label: value.text,
                         value: key,
                         default: filteredTypes.includes(key),
                         emoji: client.emojis.resolve(getEmojiByName(value.emoji, "id"))
-                }))
-            ).setMinValues(1).setMaxValues(Object.keys(types).length).setCustomId("filter").setPlaceholder("Select at least one event")])
-        ] : []).concat([
+                    }))
+                ).setMinValues(1).setMaxValues(Object.keys(types).length).setCustomId("filter").setPlaceholder("Select at least one event")])
+            ] : []).concat([
             new MessageActionRow().addComponents([
                 new MessageButton()
                     .setCustomId("prevYear")
@@ -126,7 +126,7 @@
                     .setLabel((currentYear + 1).toString())
                     .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
                     .setStyle("SECONDARY")
-                    .setDisabled(currentYear === new Date().getFullYear()),
+                    .setDisabled(currentYear === new Date().getFullYear())
             ]), new MessageActionRow().addComponents([
                 new MessageButton()
                     .setLabel("Mod notes")
@@ -139,14 +139,14 @@
                     .setStyle(openFilterPane ? "SUCCESS" : "PRIMARY")
                     .setEmoji(getEmojiByName("ICONS.FILTER", "id"))
             ])
-        ])
-        let end = "\n\nJanuary " + currentYear.toString() + pageIndicator(
+        ]);
+        const 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.toString()
+        ) + " " + currentYear.toString();
         if (groups.length > 0) {
-            let toRender = groups[Math.min(pageIndex, groups.length - 1)]
+            const toRender = groups[Math.min(pageIndex, groups.length - 1)];
             m = await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("MEMBER.JOIN")
                 .setTitle("Moderation history for " + member.user.username)
@@ -158,7 +158,7 @@
             m = await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("MEMBER.JOIN")
                 .setTitle("Moderation history for " + member.user.username)
-                .setDescription(`**${currentYear}**\n\n*No events*` + `\n\n` + end)
+                .setDescription(`**${currentYear}**\n\n*No events*` + "\n\n" + end)
                 .setStatus("Success")
                 .setFooter({text: (openFilterPane && filteredTypes.length) ? "Filters are currently enabled" : ""})
             ], components: components});
@@ -174,9 +174,9 @@
                 .setStatus("Danger")
                 .setFooter({text: "Message timed out"})
             ]});
-            return 0
+            return 0;
         }
-        i.deferUpdate()
+        i.deferUpdate();
         if (i.customId === "filter") {
             filteredTypes = i.values;
             pageIndex = null;
@@ -193,15 +193,15 @@
             if (pageIndex >= groups.length) { pageIndex = 0; currentYear++; refresh = true; }
         }
         if (i.customId === "today") { currentYear = new Date().getFullYear(); pageIndex = null; refresh = true; }
-        if (i.customId === "modNotes") { return 1 }
-        if (i.customId === "openFilter") { openFilterPane = !openFilterPane; refresh = true }
+        if (i.customId === "modNotes") { return 1; }
+        if (i.customId === "openFilter") { openFilterPane = !openFilterPane; refresh = true; }
     }
 }
 
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    let member = (interaction.options.getMember("user")) as Discord.GuildMember;
+    const member = (interaction.options.getMember("user")) as Discord.GuildMember;
     await interaction.reply({embeds: [new EmojiEmbed()
         .setEmoji("NUCLEUS.LOADING")
         .setTitle("Downloading Data")
@@ -233,9 +233,9 @@
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { return }
+        } catch (e) { return; }
         if (i.customId === "modify") {
-            await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Editing moderator note`).addComponents(
+            await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Editing moderator note").addComponents(
                 new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
                     .setCustomId("note")
                     .setLabel("Note")
@@ -244,7 +244,7 @@
                     .setStyle("PARAGRAPH")
                     .setValue(note ? note : "")
                 )
-            ))
+            ));
             await interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Mod notes for " + member.user.username)
@@ -260,24 +260,24 @@
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
-            } catch (e) { continue }
+                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;
+                const toAdd = out.fields.getTextInputValue("note") || null;
                 await client.database.notes.create(member.guild.id, member.id, toAdd);
-            } else { continue }
+            } else { continue; }
         } else if (i.customId === "history") {
             i.deferUpdate();
-            if (!await showHistory(member, interaction) ) return
+            if (!await showHistory(member, interaction) ) return;
         }
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as GuildMember)
+    const member = (interaction.member as GuildMember);
     if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
-    return true
-}
+    return true;
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index ef748e8..b9b1b2a 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,5 +1,5 @@
 import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
-import humanizeDuration from 'humanize-duration';
+import humanizeDuration from "humanize-duration";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -9,16 +9,16 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("kick")
-    .setDescription("Kicks a user from the server")
-    .addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true))
+        .setName("kick")
+        .setDescription("Kicks a user from the server")
+        .addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser } = client.logger
+    const { renderUser } = client.logger;
     // TODO:[Modals] Replace this with a modal
     let reason = null;
     let notify = true;
-    let confirmation
+    let confirmation;
     while (true) {
         confirmation = await new confirmationMessage(interaction)
             .setEmoji("PUNISH.KICK.RED")
@@ -27,23 +27,23 @@
                 "user": renderUser(interaction.options.getUser("user")),
                 "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
             })
-            + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+            + `The user **will${notify ? "" : " not"}** be notified\n\n`
             + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
             .setColor("Danger")
             .addReasonButton(reason ?? "")
-        .send(reason !== null)
-        reason = reason ?? ""
-        if (confirmation.cancelled) return
-        if (confirmation.success) break
-        if (confirmation.newReason) reason = confirmation.newReason
+            .send(reason !== null);
+        reason = reason ?? "";
+        if (confirmation.cancelled) return;
+        if (confirmation.success) break;
+        if (confirmation.newReason) reason = confirmation.newReason;
         if (confirmation.components) {
-            notify = confirmation.components.notify.active
+            notify = confirmation.components.notify.active;
         }
     }
     if (confirmation.success) {
-        let dmd = false
+        let dmd = false;
         let dm;
-        let config = await client.database.guilds.read(interaction.guild.id);
+        const config = await client.database.guilds.read(interaction.guild.id);
         try {
             if (notify) {
                 dm = await (interaction.options.getMember("user") as GuildMember).send({
@@ -59,20 +59,20 @@
                         .setLabel(config.moderation.kick.text)
                         .setURL(config.moderation.kick.link)
                     ] : [])]
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
+        } catch { dmd = false; }
         try {
-            (interaction.options.getMember("user") as GuildMember).kick(reason ?? "No reason provided.")
-            let member = (interaction.options.getMember("user") as GuildMember)
-            try { await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason) } catch {}
-            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
-            let data = {
+            (interaction.options.getMember("user") as GuildMember).kick(reason ?? "No reason provided.");
+            const member = (interaction.options.getMember("user") as GuildMember);
+            await client.database.history.create("kick", interaction.guild.id, member.user, interaction.user, reason);
+            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+            const data = {
                 meta: {
-                    type: 'memberKick',
-                    displayName: 'Member Kicked',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberKick",
+                    displayName: "Member Kicked",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.red,
                     emoji: "PUNISH.KICK.RED",
                     timestamp: new Date().getTime()
@@ -86,64 +86,64 @@
                     reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
                     timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedTimestamp, { round: true })),
                     accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                    serverMemberCount: member.guild.memberCount,
+                    serverMemberCount: member.guild.memberCount
                 },
                 hidden: {
                     guild: member.guild.id
                 }
-            }
+            };
             log(data);
         } catch {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.KICK.RED")
-                .setTitle(`Kick`)
+                .setTitle("Kick")
                 .setDescription("Something went wrong and the user was not kicked")
                 .setStatus("Danger")
-            ], components: []})
-            if (dmd) await dm.delete()
-            return
+            ], components: []});
+            if (dmd) await dm.delete();
+            return;
         }
-        let failed = (dmd === false && notify)
+        const failed = (dmd === false && notify);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
-            .setTitle(`Kick`)
+            .setTitle("Kick")
             .setDescription("The member was kicked" + (failed ? ", but could not be notified" : ""))
             .setStatus(failed ? "Warning" : "Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.KICK.GREEN")
-            .setTitle(`Kick`)
+            .setTitle("Kick")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow kicking the owner
-    if (member.id === interaction.guild.ownerId) throw "You cannot kick the owner of the server"
+    if (member.id === interaction.guild.ownerId) throw "You cannot kick the owner of the server";
     // Check if Nucleus can kick the member
-    if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+    if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to kick
     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";
     // Check if the user is below on the role list
-    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow kick
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 808d22d..183c487 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -12,30 +12,30 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("mute")
-    .setDescription("Mutes a member, stopping them from talking in the server")
-    .addUserOption(option => option.setName("user").setDescription("The user to mute").setRequired(true))
-    .addIntegerOption(option => option.setName("days").setDescription("The number of days to mute the user for | Default: 0").setMinValue(0).setMaxValue(27).setRequired(false))
-    .addIntegerOption(option => option.setName("hours").setDescription("The number of hours to mute the user for | Default: 0").setMinValue(0).setMaxValue(23).setRequired(false))
-    .addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
-    .addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
+        .setName("mute")
+        .setDescription("Mutes a member, stopping them from talking in the server")
+        .addUserOption(option => option.setName("user").setDescription("The user to mute").setRequired(true))
+        .addIntegerOption(option => option.setName("days").setDescription("The number of days to mute the user for | Default: 0").setMinValue(0).setMaxValue(27).setRequired(false))
+        .addIntegerOption(option => option.setName("hours").setDescription("The number of hours to mute the user for | Default: 0").setMinValue(0).setMaxValue(23).setRequired(false))
+        .addIntegerOption(option => option.setName("minutes").setDescription("The number of minutes to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false))
+        .addIntegerOption(option => option.setName("seconds").setDescription("The number of seconds to mute the user for | Default: 0").setMinValue(0).setMaxValue(59).setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger
-    const user = interaction.options.getMember("user") as GuildMember
+    const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
+    const user = interaction.options.getMember("user") as GuildMember;
     const time = {
         days: interaction.options.getInteger("days") || 0,
         hours: interaction.options.getInteger("hours") || 0,
         minutes: interaction.options.getInteger("minutes") || 0,
         seconds: interaction.options.getInteger("seconds") || 0
-    }
-    let config = await client.database.guilds.read(interaction.guild.id)
-    let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "")
-    if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`
+    };
+    const config = await client.database.guilds.read(interaction.guild.id);
+    let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "");
+    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
+    let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds;
     if (muteTime === 0) {
-        let m = await interaction.reply({embeds: [
+        const m = await interaction.reply({embeds: [
             new EmojiEmbed()
                 .setEmoji("PUNISH.MUTE.GREEN")
                 .setTitle("Mute")
@@ -85,30 +85,30 @@
                     .setStyle("DANGER")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
             ])
-        ], ephemeral: true, fetchReply: true})
+        ], ephemeral: true, fetchReply: true});
         let component;
         try {
             component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
-        } catch { return }
+        } catch { return; }
         component.deferUpdate();
         if (component.customId === "cancel") return interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.MUTE.RED")
             .setTitle("Mute")
             .setDescription("Mute cancelled")
             .setStatus("Danger")
-        ]})
+        ]});
         switch (component.customId) {
-            case "1m": { muteTime = 60; break; }
-            case "10m": { muteTime = 60 * 10; break; }
-            case "30m": { muteTime = 60 * 30; break; }
-            case "1h": { muteTime = 60 * 60; break; }
-            case "6h": { muteTime = 60 * 60 * 6; break; }
-            case "12h": { muteTime = 60 * 60 * 12; break; }
-            case "1d": { muteTime = 60 * 60 * 24; break; }
-            case "1w": { muteTime = 60 * 60 * 24 * 7; break; }
+        case "1m": { muteTime = 60; break; }
+        case "10m": { muteTime = 60 * 10; break; }
+        case "30m": { muteTime = 60 * 30; break; }
+        case "1h": { muteTime = 60 * 60; break; }
+        case "6h": { muteTime = 60 * 60 * 6; break; }
+        case "12h": { muteTime = 60 * 60 * 12; break; }
+        case "1d": { muteTime = 60 * 60 * 24; break; }
+        case "1w": { muteTime = 60 * 60 * 24 * 7; break; }
         }
     } else {
-        await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
+        await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     }
     // TODO:[Modals] Replace this with a modal
     let reason = null;
@@ -124,8 +124,8 @@
                 "time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
                 "reason": reason ?  ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
             })
-            + `The user will be ` + serverSettingsDescription + "\n"
-            + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+            + "The user will be " + serverSettingsDescription + "\n"
+            + `The user **will${notify ? "" : " not"}** be notified\n\n`
             + `Are you sure you want to mute <@!${user.id}>?`)
             .setColor("Danger")
             .addCustomBoolean(
@@ -134,20 +134,20 @@
                 "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
             .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
             .addReasonButton(reason ?? "")
-        .send(true)
-        reason = reason ?? ""
-        if (confirmation.cancelled) return
-        if (confirmation.success) break
-        if (confirmation.newReason) reason = confirmation.newReason
+            .send(true);
+        reason = reason ?? "";
+        if (confirmation.cancelled) return;
+        if (confirmation.success) break;
+        if (confirmation.newReason) reason = confirmation.newReason;
         if (confirmation.components) {
-            notify = confirmation.components.notify.active
-            createAppealTicket = confirmation.components.appeal.active
+            notify = confirmation.components.notify.active;
+            createAppealTicket = confirmation.components.appeal.active;
         }
     }
     if (confirmation.success) {
-        let dmd = false
+        let dmd = false;
         let dm;
-        let config = await client.database.guilds.read(interaction.guild.id);
+        const config = await client.database.guilds.read(interaction.guild.id);
         try {
             if (notify) {
                 dm = await user.send({
@@ -157,7 +157,7 @@
                         .setDescription(`You have been muted in ${interaction.guild.name}` +
                                     (reason ? ` for:\n> ${reason}` : ".\n\n" +
                                     `You will be unmuted at: <t:${Math.round((new Date).getTime() / 1000) + muteTime}:D> at <t:${Math.round((new Date).getTime() / 1000) + muteTime}:T> (<t:${Math.round((new Date).getTime() / 1000) + muteTime}:R>)`) +
-                                    (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ``))
+                                    (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ""))
                         .setStatus("Danger")
                     ],
                     components: [new MessageActionRow().addComponents(config.moderation.mute.text ? [new MessageButton()
@@ -165,60 +165,60 @@
                         .setLabel(config.moderation.mute.text)
                         .setURL(config.moderation.mute.link)
                     ] : [])]
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
-        let member = user
-        let errors = 0
+        } catch { dmd = false; }
+        const member = user;
+        let errors = 0;
         try {
             if (config.moderation.mute.timeout) {
-                await member.timeout(muteTime * 1000, reason || "No reason provided")
+                await member.timeout(muteTime * 1000, reason || "No reason provided");
                 if (config.moderation.mute.role !== null) {
-                    await member.roles.add(config.moderation.mute.role)
+                    await member.roles.add(config.moderation.mute.role);
                     await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
                         guild: interaction.guild.id,
                         user: user.id,
                         expires: new Date().getTime() + muteTime * 1000
-                    })
+                    });
                 }
             }
-        } catch { errors++ }
+        } catch { errors++; }
         try {
             if (config.moderation.mute.role !== null) {
-                await member.roles.add(config.moderation.mute.role)
+                await member.roles.add(config.moderation.mute.role);
                 await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
                     guild: interaction.guild.id,
                     user: user.id,
                     role: config.moderation.mute.role
-                })
+                });
             }
-        } catch (e){ console.log(e); errors++ }
+        } catch (e){ console.log(e); errors++; }
         if (errors === 2) {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.MUTE.RED")
-                .setTitle(`Mute`)
+                .setTitle("Mute")
                 .setDescription("Something went wrong and the user was not muted")
                 .setStatus("Danger")
-            ], components: []}) // TODO: make this clearer
-            if (dmd) await dm.delete()
-            return
+            ], components: []}); // TODO: make this clearer
+            if (dmd) await dm.delete();
+            return;
         }
-        try { await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason) } catch {}
-        let failed = (dmd === false && notify)
+        await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
+        const failed = (dmd === false && notify);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
-            .setTitle(`Mute`)
-            .setDescription("The member was muted" + (failed ? ", but could not be notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ``))
+            .setTitle("Mute")
+            .setDescription("The member was muted" + (failed ? ", but could not be notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
             .setStatus(failed ? "Warning" : "Success")
-        ], components: []})
-        let data = {
+        ], components: []});
+        const data = {
             meta:{
-                type: 'memberMute',
-                displayName: 'Member Muted',
-                calculateType: 'guildMemberPunish',
+                type: "memberMute",
+                displayName: "Member Muted",
+                calculateType: "guildMemberPunish",
                 color: NucleusColors.yellow,
-                emoji: 'PUNISH.WARN.YELLOW',
+                emoji: "PUNISH.WARN.YELLOW",
                 timestamp: new Date().getTime()
             },
             list: {
@@ -227,47 +227,47 @@
                 mutedUntil: entry(new Date().getTime() + muteTime * 1000, renderDelta(new Date().getTime() + muteTime * 1000)),
                 muted: entry(new Date().getTime(), renderDelta(new Date().getTime() - 1000)),
                 mutedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
-                reason: entry(reason, reason ? reason : '*No reason provided*')
+                reason: entry(reason, reason ? reason : "*No reason provided*")
             },
             hidden: {
                 guild: interaction.guild.id
             }
-        }
+        };
         log(data);
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.MUTE.GREEN")
-            .setTitle(`Mute`)
+            .setTitle("Mute")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow muting the owner
-    if (member.id === interaction.guild.ownerId) throw "You cannot mute the owner of the server"
+    if (member.id === interaction.guild.ownerId) throw "You cannot mute the owner of the server";
     // Check if Nucleus can mute the member
-    if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+    if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to mute
     if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
     // 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";
     // Check if the user is below on the role list
-    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow mute
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index d50becd..9cc8a7c 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -5,17 +5,17 @@
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import keyValueList from "../../utils/generateKeyValueList.js";
 import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("nick")
-    .setDescription("Changes a users nickname")
-    .addUserOption(option => option.setName("user").setDescription("The user to change").setRequired(true))
-    .addStringOption(option => option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false))
+        .setName("nick")
+        .setDescription("Changes a users nickname")
+        .addUserOption(option => option.setName("user").setDescription("The user to change").setRequired(true))
+        .addStringOption(option => option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser } = client.logger
+    const { renderUser } = client.logger;
     // TODO:[Modals] Replace this with a modal
     let notify = true;
     let confirmation;
@@ -27,19 +27,19 @@
                 "user": renderUser(interaction.options.getUser("user")),
                 "new nickname": `${interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"}`
             })
-            + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+            + `The user **will${notify ? "" : " not"}** be notified\n\n`
             + `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`)
             .setColor("Danger")
             .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
-        .send(interaction.options.getString("name") !== null)
-        if (confirmation.cancelled) return
-        if (confirmation.success) break
+            .send(interaction.options.getString("name") !== null);
+        if (confirmation.cancelled) return;
+        if (confirmation.success) break;
         if (confirmation.components) {
-            notify = confirmation.components.notify.active
+            notify = confirmation.components.notify.active;
         }
     }
     if (confirmation.success) {
-        let dmd = false
+        let dmd = false;
         let dm;
         try {
             if (notify) {
@@ -49,94 +49,94 @@
                         .setTitle("Nickname changed")
                         .setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}.` +
                                     (interaction.options.getString("name") ? ` it is now: ${interaction.options.getString("name")}` : "") + "\n\n" +
-                                    (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ``))
+                                    (confirmation.components.appeal.response ? `You can appeal this here: <#${confirmation.components.appeal.response}>` : ""))
                         .setStatus("Danger")
                     ]
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
+        } catch { dmd = false; }
         try {
-            let member = (interaction.options.getMember("user") as GuildMember)
-            let before = member.nickname
-            let nickname = interaction.options.getString("name")
-            member.setNickname(nickname ?? null, "Nucleus Nickname command")
-            try { await client.database.history.create(
+            const member = (interaction.options.getMember("user") as GuildMember);
+            const before = member.nickname;
+            const nickname = interaction.options.getString("name");
+            member.setNickname(nickname ?? null, "Nucleus Nickname command");
+            await client.database.history.create(
                 "nickname", interaction.guild.id, member.user, interaction.user,
-                null, before, nickname) } catch {}
-            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
-            let data = {
+                null, before, nickname);
+            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+            const data = {
                 meta: {
-                    type: 'memberUpdate',
-                    displayName: 'Member Updated',
-                    calculateType: 'guildMemberUpdate',
+                    type: "memberUpdate",
+                    displayName: "Member Updated",
+                    calculateType: "guildMemberUpdate",
                     color: NucleusColors.yellow,
                     emoji: "PUNISH.NICKNAME.YELLOW",
                     timestamp: new Date().getTime()
                 },
                 list: {
                     memberId: entry(member.id, `\`${member.id}\``),
-                    before: entry(before, before ? before : '*None*'),
-                    after: entry(nickname, nickname ? nickname : '*None*'),
+                    before: entry(before, before ? before : "*None*"),
+                    after: entry(nickname, nickname ? nickname : "*None*"),
                     updated: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     updatedBy: entry(interaction.user.id, renderUser(interaction.user))
                 },
                 hidden: {
                     guild: interaction.guild.id
                 }
-            }
+            };
             log(data);
         } catch {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.NICKNAME.RED")
-                .setTitle(`Nickname`)
+                .setTitle("Nickname")
                 .setDescription("Something went wrong and the users nickname could not be changed.")
                 .setStatus("Danger")
-            ], components: []})
-            if (dmd) await dm.delete()
-            return
+            ], components: []});
+            if (dmd) await dm.delete();
+            return;
         }
-        let failed = (dmd === false && notify)
+        const failed = (dmd === false && notify);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
-            .setTitle(`Nickname`)
-            .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ``))
+            .setTitle("Nickname")
+            .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
             .setStatus(failed ? "Warning" : "Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.NICKNAME.GREEN")
-            .setTitle(`Nickname`)
+            .setTitle("Nickname")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow any changing of the owner
-    if (member.id === interaction.guild.ownerId) throw "You cannot change the owner's nickname"
+    if (member.id === interaction.guild.ownerId) throw "You cannot change the owner's nickname";
     // Check if Nucleus can change the nickname
-    if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+    if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to change the nickname
     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";
     // 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"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow change
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index 521d8a7..13e688b 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -9,20 +9,20 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("purge")
-    .setDescription("Bulk deletes messages in a channel")
-    .addIntegerOption(option => option
-        .setName("amount")
-        .setDescription("The amount of messages to delete")
-        .setRequired(false)
-        .setMinValue(1)
-        .setMaxValue(100))
-    .addUserOption(option => option.setName("user").setDescription("The user to purge messages from").setRequired(false))
-    .addStringOption(option => option.setName("reason").setDescription("The reason for the purge").setRequired(false))
+        .setName("purge")
+        .setDescription("Bulk deletes messages in a channel")
+        .addIntegerOption(option => option
+            .setName("amount")
+            .setDescription("The amount of messages to delete")
+            .setRequired(false)
+            .setMinValue(1)
+            .setMaxValue(100))
+        .addUserOption(option => option.setName("user").setDescription("The user to purge messages from").setRequired(false))
+        .addStringOption(option => option.setName("reason").setDescription("The reason for the purge").setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let user = interaction.options.getMember("user") as GuildMember ?? null
-    let channel = (interaction.channel as GuildChannel)
+    const user = interaction.options.getMember("user") as GuildMember ?? null;
+    const channel = (interaction.channel as GuildChannel);
     if (!(["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(channel.type.toString()))) {
         return await interaction.reply({
             embeds: [
@@ -33,8 +33,8 @@
                     .setStatus("Danger")
             ],
             components: [],
-            ephemeral: true,
-        })
+            ephemeral: true
+        });
     }
     // TODO:[Modals] Replace this with a modal
     if ( !interaction.options.getInteger("amount") ) {
@@ -49,10 +49,10 @@
             components: [],
             ephemeral: true,
             fetchReply: true
-        })
-        let deleted = [] as Discord.Message[]
+        });
+        let deleted = [] as Discord.Message[];
         while (true) {
-            let m = await interaction.editReply({
+            const m = await interaction.editReply({
                 embeds: [
                     new EmojiEmbed()
                         .setEmoji("CHANNEL.PURGE.RED")
@@ -74,8 +74,8 @@
                             .setCustomId("5")
                             .setLabel("5")
                             .setStyle("SECONDARY")
-                        ]),
-                        new Discord.MessageActionRow().addComponents([
+                    ]),
+                    new Discord.MessageActionRow().addComponents([
                         new Discord.MessageButton()
                             .setCustomId("10")
                             .setLabel("10")
@@ -97,7 +97,7 @@
                             .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
                     ])
                 ]
-            })
+            });
             let component;
             try {
                 component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
@@ -109,12 +109,12 @@
             let messages;
             await (interaction.channel as TextChannel).messages.fetch({limit: amount}).then(async (ms) => {
                 if (user) {
-                    ms = ms.filter(m => m.author.id === user.id)
+                    ms = ms.filter(m => m.author.id === user.id);
                 }
                 messages = await (channel as TextChannel).bulkDelete(ms, true);
-            })
+            });
             if (messages) {
-                deleted = deleted.concat(messages.map(m => m))
+                deleted = deleted.concat(messages.map(m => m));
             }
         }
         if (deleted.length === 0) return await interaction.editReply({
@@ -126,49 +126,46 @@
                     .setStatus("Danger")
             ],
             components: []
-        })
+        });
         if (user) {
-            try { await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, deleted.length) } catch {}
+            await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, deleted.length);
         }
-        let attachmentObject;
-        try {
-            const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
-            let data = {
-                meta: {
-                    type: 'channelPurge',
-                    displayName: 'Channel Purged',
-                    calculateType: 'messageDelete',
-                    color: NucleusColors.red,
-                    emoji: "PUNISH.BAN.RED",
-                    timestamp: new Date().getTime()
-                },
-                list: {
-                    memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                    purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                    channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
-                    messagesCleared: entry(deleted.length, deleted.length),
-                },
-                hidden: {
-                    guild: interaction.guild.id
-                }
+        const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+        const data = {
+            meta: {
+                type: "channelPurge",
+                displayName: "Channel Purged",
+                calculateType: "messageDelete",
+                color: NucleusColors.red,
+                emoji: "PUNISH.BAN.RED",
+                timestamp: new Date().getTime()
+            },
+            list: {
+                memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+                messagesCleared: entry(deleted.length, deleted.length)
+            },
+            hidden: {
+                guild: interaction.guild.id
             }
-            log(data);
-            let out = ""
-            deleted.reverse().forEach(message => {
-                out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`
-                let lines = message.content.split("\n")
-                lines.forEach(line => {out += `> ${line}\n`})
-                out += `\n\n`
-            })
-            attachmentObject = {
-                attachment: Buffer.from(out),
-                name: `purge-${channel.id}-${Date.now()}.txt`,
-                description: "Purge log"
-            }
-        } catch {}
-        let m = await interaction.editReply({embeds: [new EmojiEmbed()
-            .setEmoji(`CHANNEL.PURGE.GREEN`)
-            .setTitle(`Purge`)
+        };
+        log(data);
+        let out = "";
+        deleted.reverse().forEach(message => {
+            out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`;
+            const lines = message.content.split("\n");
+            lines.forEach(line => {out += `> ${line}\n`;});
+            out += "\n\n";
+        });
+        const attachmentObject = {
+            attachment: Buffer.from(out),
+            name: `purge-${channel.id}-${Date.now()}.txt`,
+            description: "Purge log"
+        };
+        const m = await interaction.editReply({embeds: [new EmojiEmbed()
+            .setEmoji("CHANNEL.PURGE.GREEN")
+            .setTitle("Purge")
             .setDescription("Messages cleared")
             .setStatus("Success")
         ], components: [new Discord.MessageActionRow().addComponents([
@@ -177,29 +174,29 @@
                 .setLabel("Download transcript")
                 .setStyle("SUCCESS")
                 .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
-        ])]})
+        ])]});
         let component;
         try {
             component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
-        } catch {}
+        } catch { return; }
         if (component && component.customId === "download") {
             interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.PURGE.GREEN")
-                .setTitle(`Purge`)
+                .setTitle("Purge")
                 .setDescription("Uploaded")
                 .setStatus("Success")
-            ], components: [], files: [attachmentObject]})
+            ], components: [], files: [attachmentObject]});
         } else {
             interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.PURGE.GREEN")
-                .setTitle(`Purge`)
+                .setTitle("Purge")
                 .setDescription("Messages cleared")
                 .setStatus("Success")
-            ], components: []})
+            ], components: []});
         }
-        return
+        return;
     } else {
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.PURGE.RED")
             .setTitle("Purge")
             .setDescription(keyValueList({
@@ -208,69 +205,66 @@
                 "reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
             }))
             .setColor("Danger")
-        .send()
-        if (confirmation.cancelled) return
+            .send();
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             let messages;
             try {
                 if (!user) {
-                    let toDelete = await (interaction.channel as TextChannel).messages.fetch({limit: interaction.options.getInteger("amount")})
+                    const toDelete = await (interaction.channel as TextChannel).messages.fetch({limit: interaction.options.getInteger("amount")});
                     messages = await (channel as TextChannel).bulkDelete(toDelete, true);
                 } else {
-                    let toDelete = (await (await (interaction.channel as TextChannel).messages.fetch({limit: 100}))
-                        .filter(m => m.author.id === user.id)).first(interaction.options.getInteger("amount"))
+                    const toDelete = (await (await (interaction.channel as TextChannel).messages.fetch({limit: 100}))
+                        .filter(m => m.author.id === user.id)).first(interaction.options.getInteger("amount"));
                     messages = await (channel as TextChannel).bulkDelete(toDelete, true);
                 }
             } catch(e) {
                 await interaction.editReply({embeds: [new EmojiEmbed()
                     .setEmoji("CHANNEL.PURGE.RED")
-                    .setTitle(`Purge`)
+                    .setTitle("Purge")
                     .setDescription("Something went wrong and no messages were deleted")
                     .setStatus("Danger")
-                ], components: []})
+                ], components: []});
             }
             if (user) {
-                try { await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, messages.size) } catch {}
+                await client.database.history.create("purge", interaction.guild.id, user, interaction.options.getString("reason"), null, null, messages.size);
             }
-            let attachmentObject;
-            try {
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
-                let data = {
-                    meta: {
-                        type: 'channelPurge',
-                        displayName: 'Channel Purged',
-                        calculateType: 'messageDelete',
-                        color: NucleusColors.red,
-                        emoji: "PUNISH.BAN.RED",
-                        timestamp: new Date().getTime()
-                    },
-                    list: {
-                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                        purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                        channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
-                        messagesCleared: entry(messages.size, messages.size),
-                    },
-                    hidden: {
-                        guild: interaction.guild.id
-                    }
+            const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+            const data = {
+                meta: {
+                    type: "channelPurge",
+                    displayName: "Channel Purged",
+                    calculateType: "messageDelete",
+                    color: NucleusColors.red,
+                    emoji: "PUNISH.BAN.RED",
+                    timestamp: new Date().getTime()
+                },
+                list: {
+                    memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                    purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                    channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+                    messagesCleared: entry(messages.size, messages.size)
+                },
+                hidden: {
+                    guild: interaction.guild.id
                 }
-                log(data);
-                let out = ""
-                messages.reverse().forEach(message => {
-                    out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`
-                    let lines = message.content.split("\n")
-                    lines.forEach(line => {out += `> ${line}\n`})
-                    out += `\n\n`
-                })
-                attachmentObject = {
-                    attachment: Buffer.from(out),
-                    name: `purge-${channel.id}-${Date.now()}.txt`,
-                    description: `Purge log`
-                }
-            } catch {}
-            let m = await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji(`CHANNEL.PURGE.GREEN`)
-                .setTitle(`Purge`)
+            };
+            log(data);
+            let out = "";
+            messages.reverse().forEach(message => {
+                out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`;
+                const lines = message.content.split("\n");
+                lines.forEach(line => {out += `> ${line}\n`;});
+                out += "\n\n";
+            });
+            const attachmentObject = {
+                attachment: Buffer.from(out),
+                name: `purge-${channel.id}-${Date.now()}.txt`,
+                description: "Purge log"
+            };
+            const m = await interaction.editReply({embeds: [new EmojiEmbed()
+                .setEmoji("CHANNEL.PURGE.GREEN")
+                .setTitle("Purge")
                 .setDescription("Messages cleared")
                 .setStatus("Success")
             ], components: [new Discord.MessageActionRow().addComponents([
@@ -279,48 +273,48 @@
                     .setLabel("Download transcript")
                     .setStyle("SUCCESS")
                     .setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
-            ])]})
+            ])]});
             let component;
             try {
                 component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
-            } catch {}
+            } catch { return; }
             if (component && component.customId === "download") {
                 interaction.editReply({embeds: [new EmojiEmbed()
                     .setEmoji("CHANNEL.PURGE.GREEN")
-                    .setTitle(`Purge`)
+                    .setTitle("Purge")
                     .setDescription("Transcript uploaded above")
                     .setStatus("Success")
-                ], components: [], files: [attachmentObject]})
+                ], components: [], files: [attachmentObject]});
             } else {
                 interaction.editReply({embeds: [new EmojiEmbed()
                     .setEmoji("CHANNEL.PURGE.GREEN")
-                    .setTitle(`Purge`)
+                    .setTitle("Purge")
                     .setDescription("Messages cleared")
                     .setStatus("Success")
-                ], components: []})
+                ], components: []});
             }
         } else {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.PURGE.GREEN")
-                .setTitle(`Purge`)
+                .setTitle("Purge")
                 .setDescription("No changes were made")
                 .setStatus("Success")
-            ], components: []})
+            ], components: []});
         }
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as GuildMember)
-    let me = (interaction.guild.me as GuildMember)
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
     // Check if nucleus has the manage_messages permission
     if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
     // 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";
     // Allow purge
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 6b33e12..951dc53 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -1,4 +1,4 @@
-import humanizeDuration from 'humanize-duration';
+import humanizeDuration from "humanize-duration";
 import { CommandInteraction, GuildMember, TextChannel } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -9,64 +9,64 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("slowmode")
-    .setDescription("Manages slowmode in a channel")
-    .addStringOption(option => option.setName("time").setDescription("The delay between messages").setRequired(false).addChoices([
-        ["Off", "0"],
-        ["5 seconds", "5"], ["10 seconds", "10"], ["15 seconds", "15"], ["30 seconds", "30"],
-        ["1 minute", "60"], ["2 minutes", "120"], ["5 minutes", "300"], ["10 minutes", "600"],
-        ["15 minutes", "900"], ["30 minutes", "1800"],
-        ["1 hour", "3600"], ["2 hours", "7200"], ["6 hours", "21600"]
-    ]))
+        .setName("slowmode")
+        .setDescription("Manages slowmode in a channel")
+        .addStringOption(option => option.setName("time").setDescription("The delay between messages").setRequired(false).addChoices([
+            ["Off", "0"],
+            ["5 seconds", "5"], ["10 seconds", "10"], ["15 seconds", "15"], ["30 seconds", "30"],
+            ["1 minute", "60"], ["2 minutes", "120"], ["5 minutes", "300"], ["10 minutes", "600"],
+            ["15 minutes", "900"], ["30 minutes", "1800"],
+            ["1 hour", "3600"], ["2 hours", "7200"], ["6 hours", "21600"]
+        ]));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let time = parseInt(interaction.options.getString("time") ?? "0");
-    if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) { time = 10 }
-    let confirmation = await new confirmationMessage(interaction)
+    if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) { time = 10; }
+    const confirmation = await new confirmationMessage(interaction)
         .setEmoji("CHANNEL.SLOWMODE.OFF")
         .setTitle("Slowmode")
         .setDescription(keyValueList({
-            "time": time ? humanizeDuration(time * 1000, { round: true }) : "No delay",
+            "time": time ? humanizeDuration(time * 1000, { round: true }) : "No delay"
         })
-        + `Are you sure you want to set the slowmode in this channel?`)
+        + "Are you sure you want to set the slowmode in this channel?")
         .setColor("Danger")
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (confirmation.success) {
         try {
-            (interaction.channel as TextChannel).setRateLimitPerUser(time)
+            (interaction.channel as TextChannel).setRateLimitPerUser(time);
         } catch (e) {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.SLOWMODE.OFF")
-                .setTitle(`Slowmode`)
+                .setTitle("Slowmode")
                 .setDescription("Something went wrong while setting the slowmode")
                 .setStatus("Danger")
-            ], components: []})
+            ], components: []});
         }
         await interaction.editReply({embeds: [new EmojiEmbed()
-            .setEmoji(`CHANNEL.SLOWMODE.ON`)
-            .setTitle(`Slowmode`)
+            .setEmoji("CHANNEL.SLOWMODE.ON")
+            .setTitle("Slowmode")
             .setDescription("The channel slowmode was set successfully")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("CHANNEL.SLOWMODE.ON")
-            .setTitle(`Slowmode`)
+            .setTitle("Slowmode")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as GuildMember)
+    const 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";
     // Check if the user has manage_channel permission
     if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the *Manage Channels* permission";
     // Allow slowmode
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 43d03fd..88ba531 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -9,43 +9,43 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("softban")
-    .setDescription("Kicks a user and deletes their messages")
-    .addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
-    .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false))
+        .setName("softban")
+        .setDescription("Kicks a user and deletes their messages")
+        .addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
+        .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser } = client.logger
+    const { renderUser } = client.logger;
     // TODO:[Modals] Replace this with a modal
     let reason = null;
     let notify = true;
     let confirmation;
     while (true) {
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("PUNISH.BAN.RED")
             .setTitle("Softban")
             .setDescription(keyValueList({
                 "user": renderUser(interaction.options.getUser("user")),
                 "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
             })
-            + `The user **will${notify ? '' : ' not'}** be notified\n`
+            + `The user **will${notify ? "" : " not"}** be notified\n`
             + `${addPlural(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
             + `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
             .setColor("Danger")
             .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
             .addReasonButton(reason ?? "")
-        .send(reason !== null)
-        reason = reason ?? ""
-        if (confirmation.cancelled) return
-        if (confirmation.success) break
-        if (confirmation.newReason) reason = confirmation.newReason
+            .send(reason !== null);
+        reason = reason ?? "";
+        if (confirmation.cancelled) return;
+        if (confirmation.success) break;
+        if (confirmation.newReason) reason = confirmation.newReason;
         if (confirmation.components) {
-            notify = confirmation.components.notify.active
+            notify = confirmation.components.notify.active;
         }
     }
     if (confirmation.success) {
         let dmd = false;
-        let config = await client.database.guilds.read(interaction.guild.id);
+        const config = await client.database.guilds.read(interaction.guild.id);
         try {
             if (notify) {
                 await (interaction.options.getMember("user") as GuildMember).send({
@@ -61,11 +61,11 @@
                         .setLabel(config.moderation.ban.text)
                         .setURL(config.moderation.ban.link)
                     ] : [])]
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
-        let member = (interaction.options.getMember("user") as GuildMember)
+        } catch { dmd = false;}
+        const member = (interaction.options.getMember("user") as GuildMember);
         try {
             await member.ban({
                 days: Number(interaction.options.getInteger("delete") ?? 0),
@@ -75,53 +75,53 @@
         } catch {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.BAN.RED")
-                .setTitle(`Softban`)
+                .setTitle("Softban")
                 .setDescription("Something went wrong and the user was not softbanned")
                 .setStatus("Danger")
-            ], components: []})
+            ], components: []});
         }
-        try { await client.database.history.create("softban", interaction.guild.id, member.user, reason) } catch {}
-        let failed = (dmd === false && notify)
+        await client.database.history.create("softban", interaction.guild.id, member.user, reason);
+        const failed = (dmd === false && notify);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
-            .setTitle(`Softban`)
+            .setTitle("Softban")
             .setDescription("The member was softbanned" + (failed ? ", but could not be notified" : ""))
             .setStatus(failed ? "Warning" : "Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.BAN.GREEN")
-            .setTitle(`Softban`)
+            .setTitle("Softban")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow softbanning the owner
-    if (member.id === interaction.guild.ownerId) throw "You cannot softban the owner of the server"
+    if (member.id === interaction.guild.ownerId) throw "You cannot softban the owner of the server";
     // Check if Nucleus can ban the member
-    if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+    if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to ban
     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 softban 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";
     // Check if the user is below on the role list
-    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow softban
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 2605d28..faf1f08 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -8,46 +8,46 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("unban")
-    .setDescription("Unbans a user")
-    .addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true))
+        .setName("unban")
+        .setDescription("Unbans a user")
+        .addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true));
 
 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())
+    const bans = await interaction.guild.bans.fetch();
+    const 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());
     if (!resolved) {
         return interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Unban")
             .setDescription(`Could not find any user called \`${user}\``)
             .setEmoji("PUNISH.UNBAN.RED")
             .setStatus("Danger")
-        ], ephemeral: true})
+        ], ephemeral: true});
     }
     // TODO:[Modals] Replace this with a modal
-    let confirmation = await new confirmationMessage(interaction)
+    const confirmation = await new confirmationMessage(interaction)
         .setEmoji("PUNISH.UNBAN.RED")
         .setTitle("Unban")
         .setDescription(keyValueList({
-            "user": `${resolved.user.username} [<@${resolved.user.id}>]`,
+            "user": `${resolved.user.username} [<@${resolved.user.id}>]`
         })
         + `Are you sure you want to unban <@${resolved.user.id}>?`)
         .setColor("Danger")
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (confirmation.success) {
         try {
             await interaction.guild.members.unban(resolved.user as User, "Unban");
-            let member = (resolved.user as User)
-            try { await client.database.history.create("unban", interaction.guild.id, member, interaction.user) } catch {}
-            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
-            let data = {
+            const member = (resolved.user as User);
+            await client.database.history.create("unban", interaction.guild.id, member, interaction.user);
+            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+            const data = {
                 meta: {
-                    type: 'memberUnban',
-                    displayName: 'Member Unbanned',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberUnban",
+                    displayName: "Member Unbanned",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.green,
                     emoji: "PUNISH.BAN.GREEN",
                     timestamp: new Date().getTime()
@@ -57,48 +57,48 @@
                     name: entry(member.id, renderUser(member)),
                     unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     unbannedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                    accountCreated: entry(member.createdAt, renderDelta(member.createdAt)),
+                    accountCreated: entry(member.createdAt, renderDelta(member.createdAt))
                 },
                 hidden: {
                     guild: interaction.guild.id
                 }
-            }
+            };
             log(data);
         } catch {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.UNBAN.RED")
-                .setTitle(`Unban`)
+                .setTitle("Unban")
                 .setDescription("Something went wrong and the user was not unbanned")
                 .setStatus("Danger")
-            ], components: []})
+            ], components: []});
         }
         await interaction.editReply({embeds: [new EmojiEmbed()
-            .setEmoji(`PUNISH.UNBAN.GREEN`)
-            .setTitle(`Unban`)
+            .setEmoji("PUNISH.UNBAN.GREEN")
+            .setTitle("Unban")
             .setDescription("The member was unbanned")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.UNBAN.GREEN")
-            .setTitle(`Unban`)
+            .setTitle("Unban")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as GuildMember)
-    let me = (interaction.guild.me as GuildMember)
+    const member = (interaction.member as GuildMember);
+    const 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";
     // 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";
     // Allow unban
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 6451837..e00c16d 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -8,12 +8,12 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("unmute")
-    .setDescription("Unmutes a user")
-    .addUserOption(option => option.setName("user").setDescription("The user to unmute").setRequired(true))
+        .setName("unmute")
+        .setDescription("Unmutes a user")
+        .addUserOption(option => option.setName("user").setDescription("The user to unmute").setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger
+    const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
     // TODO:[Modals] Replace this with a modal
     let reason = null;
     let notify = false;
@@ -26,20 +26,20 @@
                 "user": renderUser(interaction.options.getUser("user")),
                 "reason": `\n> ${reason ? reason : "*No reason provided*"}`
             })
-            + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+            + `The user **will${notify ? "" : " not"}** be notified\n\n`
             + `Are you sure you want to unmute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
             .setColor("Danger")
             .addReasonButton(reason ?? "")
-        .send(reason !== null)
-        if (confirmation.success) break
-        if (confirmation.newReason) reason = confirmation.newReason
+            .send(reason !== null);
+        if (confirmation.success) break;
+        if (confirmation.newReason) reason = confirmation.newReason;
         if (confirmation.components) {
-            notify = confirmation.components.notify.active
+            notify = confirmation.components.notify.active;
         }
     }
-    if (confirmation.cancelled) return
+    if (confirmation.cancelled) return;
     if (confirmation.success) {
-        let dmd = false
+        let dmd = false;
         let dm;
         try {
             if (notify) {
@@ -51,29 +51,29 @@
                                     (reason ? ` for:\n> ${reason}` : " with no reason provided."))
                         .setStatus("Success")
                     ]
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
-        let member = (interaction.options.getMember("user") as GuildMember)
+        } catch { dmd = false; }
+        const member = (interaction.options.getMember("user") as GuildMember);
         try {
-            member.timeout(0, reason || "No reason provided")
+            member.timeout(0, reason || "No reason provided");
         } catch {
             await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("PUNISH.MUTE.RED")
-                .setTitle(`Unmute`)
+                .setTitle("Unmute")
                 .setDescription("Something went wrong and the user was not unmuted")
                 .setStatus("Danger")
-            ], components: []})
-            if (dmd) await dm.delete()
-            return
+            ], components: []});
+            if (dmd) await dm.delete();
+            return;
         }
-        try { await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, reason) } catch {}
-        let data = {
+        await client.database.history.create("unmute", interaction.guild.id, (interaction.options.getMember("user") as GuildMember).user, interaction.user, reason);
+        const data = {
             meta: {
-                type: 'memberUnmute',
-                displayName: 'Unmuted',
-                calculateType: 'guildMemberPunish',
+                type: "memberUnmute",
+                displayName: "Unmuted",
+                calculateType: "guildMemberPunish",
                 color: NucleusColors.green,
                 emoji: "PUNISH.MUTE.GREEN",
                 timestamp: new Date().getTime()
@@ -82,52 +82,52 @@
                 memberId: entry(member.user.id, `\`${member.user.id}\``),
                 name: entry(member.user.id, renderUser(member.user)),
                 unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                unmutedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
             },
             hidden: {
                 guild: interaction.guild.id
             }
-        }
+        };
         log(data);
-        let failed = (dmd === false && notify)
+        const failed = (dmd === false && notify);
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
-            .setTitle(`Unmute`)
+            .setTitle("Unmute")
             .setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
             .setStatus(failed ? "Warning" : "Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.MUTE.GREEN")
-            .setTitle(`Unmute`)
+            .setTitle("Unmute")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow unmuting the owner
-    if (member.id === interaction.guild.ownerId) throw "You cannot unmute the owner of the server"
+    if (member.id === interaction.guild.ownerId) throw "You cannot unmute the owner of the server";
     // Check if Nucleus can unmute the member
-    if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
+    if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
     // Check if Nucleus has permission to unmute
     if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
     // 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";
     // Check if the user is below on the role list
-    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow unmute
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index 2f5cacc..a5bf5ea 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -7,40 +7,40 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("viewas")
-    .setDescription("View the server as a specific member")
-    .addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true))
+        .setName("viewas")
+        .setDescription("View the server as a specific member")
+        .addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let channels = [];
     let m;
     interaction.guild.channels.cache.forEach(channel => {
-        if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel)
-    })
-    channels = [channels]
+        if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel);
+    });
+    channels = [channels];
     channels = channels.concat(interaction.guild.channels.cache
         .filter(c => c.type === "GUILD_CATEGORY")
         .map(c => (c as CategoryChannel).children.map(c => c))
-    )
-    let autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"]
+    );
+    const autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"];
     channels = channels.map(c => c.sort((a, b) => {
-        if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.position - b.position
-        if (autoSortBelow.includes(a.type)) return 1
-        if (autoSortBelow.includes(b.type)) return -1
-        return a.position - b.position
-    }))
+        if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.position - b.position;
+        if (autoSortBelow.includes(a.type)) return 1;
+        if (autoSortBelow.includes(b.type)) return -1;
+        return a.position - b.position;
+    }));
     // Sort all arrays by the position of the first channels parent position
     channels = channels.sort((a, b) => {
-        if (!a[0].parent) return -1
-        if (!b[0].parent) return 1
-        return a[0].parent.position - b[0].parent.position
-    })
-    let member = interaction.options.getMember("member") as Discord.GuildMember
+        if (!a[0].parent) return -1;
+        if (!b[0].parent) return 1;
+        return a[0].parent.position - b[0].parent.position;
+    });
+    const member = interaction.options.getMember("member") as Discord.GuildMember;
     m = await interaction.reply({embeds: [new EmojiEmbed()
         .setEmoji("MEMBER.JOIN")
         .setTitle("Viewing as " + member.displayName)
         .setStatus("Success")
-    ], ephemeral: true, fetchReply: true})
+    ], ephemeral: true, fetchReply: true});
     let page = 0;
     while (true) {
         m = await interaction.editReply({embeds: [new EmojiEmbed()
@@ -50,17 +50,17 @@
             .setDescription(
                 `**${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"
-                    else if ("nsfw" in c && c.nsfw) channelType += "_NSFW"
+                    let channelType = c.type;
+                    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` + (() => {
                             if ("threads" in c && c.threads.cache.size > 0) {
                                 return c.threads.cache.map(t => ` ${
                                     getEmojiByName("ICONS.CHANNEL.THREAD_PIPE") + " " +
-                                    getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")} ${t.name}`).join("\n") + "\n"
-                            }return ""
-                        })()) : ""
+                                    getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")} ${t.name}`).join("\n") + "\n";
+                            }return "";
+                        })()) : "";
                 }).join("") + "\n" + pageIndicator(channels.length, page)
             )
         ], components: [
@@ -83,23 +83,23 @@
                     .setStyle("PRIMARY")
                     .setCustomId("next")
             ])
-        ]})
+        ]});
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { return }
-        i.deferUpdate()
+        } catch (e) { return; }
+        i.deferUpdate();
         if (i.customId === "next") { page++; }
         else if (i.customId === "previous") { page--; }
         else if (i.customId === "select") { page = parseInt(i.values[0]); }
     }
-}
+};
 
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as GuildMember)
+    const member = (interaction.member as GuildMember);
     if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index b007b29..0648f66 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -5,16 +5,16 @@
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import keyValueList from "../../utils/generateKeyValueList.js";
 import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("warn")
-    .setDescription("Warns a user")
-    .addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true))
+        .setName("warn")
+        .setDescription("Warns a user")
+        .addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { log, NucleusColors, renderUser, entry } = client.logger
+    const { log, NucleusColors, renderUser, entry } = client.logger;
     // TODO:[Modals] Replace this with a modal
     let reason = null;
     let notify = true;
@@ -28,7 +28,7 @@
                 "user": renderUser(interaction.options.getUser("user")),
                 "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
             })
-            + `The user **will${notify ? '' : ' not'}** be notified\n\n`
+            + `The user **will${notify ? "" : " not"}** be notified\n\n`
             + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
             .setColor("Danger")
             .addCustomBoolean(
@@ -37,28 +37,28 @@
                 "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
             .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
             .addReasonButton(reason ?? "")
-        .send(reason !== null)
-        reason = reason ?? ""
-        if (confirmation.cancelled) return
-        if (confirmation.success) break
-        if (confirmation.newReason) reason = confirmation.newReason
+            .send(reason !== null);
+        reason = reason ?? "";
+        if (confirmation.cancelled) return;
+        if (confirmation.success) break;
+        if (confirmation.newReason) reason = confirmation.newReason;
         if (confirmation.components) {
-            notify = confirmation.components.notify.active
-            createAppealTicket = confirmation.components.appeal.active
+            notify = confirmation.components.notify.active;
+            createAppealTicket = confirmation.components.appeal.active;
         }
     }
     if (confirmation.success) {
-        let dmd = false
+        let dmd = false;
         try {
             if (notify) {
-                const config = await client.database.guilds.read(interaction.guild.id)
+                const config = await client.database.guilds.read(interaction.guild.id);
                 await (interaction.options.getMember("user") as GuildMember).send({
                     embeds: [new EmojiEmbed()
                         .setEmoji("PUNISH.WARN.RED")
                         .setTitle("Warned")
                         .setDescription(`You have been warned in ${interaction.guild.name}` +
                                     (reason ? ` for:\n> ${reason}` : ".") + "\n\n" +
-                                    (confirmation.components.appeal.response ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>` : ``))
+                                    (confirmation.components.appeal.response ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>` : ""))
                         .setStatus("Danger")
                         .setFooter({
                             text: config.moderation.warn.text ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site." : "",
@@ -70,17 +70,17 @@
                         .setLabel(config.moderation.warn.text)
                         .setURL(config.moderation.warn.link)
                     ])] : []
-                })
-                dmd = true
+                });
+                dmd = true;
             }
-        } catch {}
-        let data = {
+        } catch { dmd = false; }
+        const data = {
             meta:{
-                type: 'memberWarn',
-                displayName: 'Member warned',
-                calculateType: 'guildMemberPunish',
+                type: "memberWarn",
+                displayName: "Member warned",
+                calculateType: "guildMemberPunish",
                 color: NucleusColors.yellow,
-                emoji: 'PUNISH.WARN.YELLOW',
+                emoji: "PUNISH.WARN.YELLOW",
                 timestamp: new Date().getTime()
             },
             list: {
@@ -91,27 +91,27 @@
             hidden: {
                 guild: interaction.guild.id
             }
-        }
-        try { await client.database.history.create(
+        };
+        await client.database.history.create(
             "warn", interaction.guild.id,
             (interaction.options.getMember("user") as GuildMember).user,
             interaction.user, reason
-        )} catch {}
+        );
         log(data);
-        let failed = (dmd === false && notify)
+        const failed = (dmd === false && notify);
         if (!failed) {
             await interaction.editReply({embeds: [new EmojiEmbed()
-                .setEmoji(`PUNISH.WARN.GREEN`)
-                .setTitle(`Warn`)
-                .setDescription("The user was warned" + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ``))
+                .setEmoji("PUNISH.WARN.GREEN")
+                .setTitle("Warn")
+                .setDescription("The user was warned" + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
                 .setStatus("Success")
-            ], components: []})
+            ], components: []});
         } else {
-            let canSeeChannel = (interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL")
-            let m = await interaction.editReply({
+            const canSeeChannel = (interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL");
+            const m = await interaction.editReply({
                 embeds: [new EmojiEmbed()
-                    .setEmoji(`PUNISH.WARN.RED`)
-                    .setTitle(`Warn`)
+                    .setEmoji("PUNISH.WARN.RED")
+                    .setTitle("Warn")
                     .setDescription("The user's DMs are not open\n\nWhat would you like to do?")
                     .setStatus("Danger")
                 ], components: [
@@ -131,89 +131,89 @@
                             .setStyle(canSeeChannel ? "SECONDARY" : "PRIMARY")
                     ])
                 ]
-            })
+            });
             let component;
             try {
                 component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
             } catch (e) {
                 return await interaction.editReply({embeds: [new EmojiEmbed()
-                    .setEmoji(`PUNISH.WARN.GREEN`)
-                    .setTitle(`Warn`)
+                    .setEmoji("PUNISH.WARN.GREEN")
+                    .setTitle("Warn")
                     .setDescription("No changes were made")
                     .setStatus("Success")
-                ], components: []})
+                ], components: []});
             }
             if ( component.customId === "here" ) {
                 await interaction.channel.send({
                     embeds: [new EmojiEmbed()
-                        .setEmoji(`PUNISH.WARN.RED`)
-                        .setTitle(`Warn`)
-                        .setDescription(`You have been warned` +
+                        .setEmoji("PUNISH.WARN.RED")
+                        .setTitle("Warn")
+                        .setDescription("You have been warned" +
                                     (reason ? ` for:\n> ${reason}` : "."))
                         .setStatus("Danger")
                     ],
                     content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
                     allowedMentions: {users: [(interaction.options.getMember("user") as GuildMember).id]}
-                })
+                });
                 return await interaction.editReply({embeds: [new EmojiEmbed()
-                    .setEmoji(`PUNISH.WARN.GREEN`)
-                    .setTitle(`Warn`)
-                    .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
+                    .setEmoji("PUNISH.WARN.GREEN")
+                    .setTitle("Warn")
+                    .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ""))
                     .setStatus("Success")
-                ], components: []})
+                ], components: []});
             } else if (component.customId === "log") {
                 await interaction.editReply({embeds: [new EmojiEmbed()
-                    .setEmoji(`PUNISH.WARN.GREEN`)
-                    .setTitle(`Warn`)
+                    .setEmoji("PUNISH.WARN.GREEN")
+                    .setTitle("Warn")
                     .setDescription("The warn was logged")
                     .setStatus("Success")
-                ], components: []})
+                ], components: []});
             } else if (component.customId === "ticket") {
-                let ticketChannel = await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason, "Warn Notification")
+                const ticketChannel = await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason, "Warn Notification");
                 if (ticketChannel === null) {
                     return await interaction.editReply({embeds: [new EmojiEmbed()
-                        .setEmoji(`PUNISH.WARN.RED`)
-                        .setTitle(`Warn`)
+                        .setEmoji("PUNISH.WARN.RED")
+                        .setTitle("Warn")
                         .setDescription("A ticket could not be created")
                         .setStatus("Danger")
-                    ], components: []})
+                    ], components: []});
                 }
                 await interaction.editReply({embeds: [new EmojiEmbed()
-                    .setEmoji(`PUNISH.WARN.GREEN`)
-                    .setTitle(`Warn`)
+                    .setEmoji("PUNISH.WARN.GREEN")
+                    .setTitle("Warn")
                     .setDescription(`A ticket was created in <#${ticketChannel}>`)
                     .setStatus("Success")
-                ], components: []})
+                ], components: []});
             }
         }
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("PUNISH.WARN.GREEN")
-            .setTitle(`Warn`)
+            .setTitle("Warn")
             .setDescription("No changes were made")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
-    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
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    if (member === null || me === null || apply === null) throw "That member is not in the server";
+    const memberPos = member.roles ? member.roles.highest.position : 0;
+    const mePos = me.roles ? me.roles.highest.position : 0;
+    const applyPos = apply.roles ? apply.roles.highest.position : 0;
     // Do not allow warning bots
-    if (member.user.bot) throw "I cannot warn 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";
     // Check if the user is below on the role list
-    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
+    if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
     // Allow warn
-    return true
-}
+    return true;
+};
 
 export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index 5f2cde2..507730b 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -7,17 +7,17 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("guide")
-    .setDescription("Shows the welcome guide for the bot")
+        .setName("guide")
+        .setDescription("Shows the welcome guide for the bot");
 
 
 const callback = async (interaction) => {
-    guide(interaction.guild, interaction)
-}
+    guide(interaction.guild, interaction);
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    return true
-}
+    return true;
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/nucleus/invite.ts b/src/commands/nucleus/invite.ts
index 96e1449..5a1ea59 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -2,12 +2,12 @@
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("invite")
-    .setDescription("Invites Nucleus to your server")
+        .setName("invite")
+        .setDescription("Invites Nucleus to your server");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     interaction.reply({embeds: [new EmojiEmbed()
@@ -20,11 +20,11 @@
         .setStyle("LINK")
         .setURL(`https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=295157886134&scope=bot%20applications.commands`)
     ])], ephemeral: true});
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/nucleus/ping.ts b/src/commands/nucleus/ping.ts
index 6353843..c153e19 100644
--- a/src/commands/nucleus/ping.ts
+++ b/src/commands/nucleus/ping.ts
@@ -1,21 +1,21 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import { CommandInteraction } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import { WrappedCheck } from "jshaiku";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("ping")
-    .setDescription("Gets the bot's ping time")
+        .setName("ping")
+        .setDescription("Gets the bot's ping time");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     // WEBSOCKET | Nucleus -> Discord
     // EDITING   | Nucleus -> discord -> nucleus | edit time / 2
-    let initial = new Date().getTime();
+    const initial = new Date().getTime();
     await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
-    let ping = new Date().getTime() - initial;
+    const ping = new Date().getTime() - initial;
     interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Ping")
         .setDescription(
@@ -25,12 +25,12 @@
         )
         .setEmoji("CHANNEL.SLOWMODE.OFF")
         .setStatus("Danger")
-    ]})
-}
+    ]});
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index 9d273b9..c8c0f76 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -5,8 +5,8 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("premium")
-    .setDescription("Information about Nucleus Premium")
+        .setName("premium")
+        .setDescription("Information about Nucleus Premium");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     interaction.reply({embeds: [new EmojiEmbed()
@@ -20,11 +20,11 @@
         .setEmoji("NUCLEUS.LOGO")
         .setStatus("Danger")
     ], ephemeral: true});
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index beea94b..98b87be 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -2,12 +2,12 @@
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("stats")
-    .setDescription("Gets the bot's stats")
+        .setName("stats")
+        .setDescription("Gets the bot's stats");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     interaction.reply({
@@ -22,11 +22,11 @@
 
         ], ephemeral: true
     });
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 0c596ff..238e7d5 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -3,55 +3,55 @@
 import { WrappedCheck } from "jshaiku";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("suggest")
-    .setDescription("Sends a suggestion to the developers")
-    .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true))
+        .setName("suggest")
+        .setDescription("Sends a suggestion to the developers")
+        .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser } = client.logger
-    let suggestion = interaction.options.getString("suggestion");
-    let confirmation = await new confirmationMessage(interaction)
+    const { renderUser } = client.logger;
+    const suggestion = interaction.options.getString("suggestion");
+    const confirmation = await new confirmationMessage(interaction)
         .setEmoji("ICONS.OPP.ADD")
         .setTitle("Suggest")
         .setDescription(`**Suggestion:**\n> ${suggestion}\n`
-        + `Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?`)
+        + "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?")
         .setColor("Danger")
         .setInverted(true)
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (confirmation.success) {
-        await (client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({
+        await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
             embeds: [
                 new EmojiEmbed()
-                    .setTitle(`Suggestion`)
+                    .setTitle("Suggestion")
                     .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
                     .setStatus("Danger")
                     .setEmoji("NUCLEUS.LOGO")
             ]
-        })
+        });
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("ICONS.ADD")
-            .setTitle(`Suggest`)
+            .setTitle("Suggest")
             .setDescription("Your suggestion was sent successfully")
             .setStatus("Success")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("ICONS.OPP.ADD")
-            .setTitle(`Suggest`)
+            .setTitle("Suggest")
             .setDescription("No changes were made")
             .setStatus("Danger")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 81d1503..ca56fcd 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -11,13 +11,13 @@
 
 const command = new SlashCommandBuilder()
     .setName("privacy")
-    .setDescription("Information and options for you and your server's settings")
+    .setDescription("Information and options for you and your server's settings");
 
 class Embed {
     embed: Discord.MessageEmbed;
     title: string;
-    description: string = "";
-    pageId: number = 0;
+    description = "";
+    pageId = 0;
     components?: MessageActionRow[] = [];
     setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
     setTitle(title: string) { this.title = title; return this; }
@@ -27,7 +27,7 @@
 }
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let pages = [
+    const pages = [
         new Embed()
             .setEmbed(new EmojiEmbed()
                 .setTitle("Nucleus Privacy")
@@ -81,43 +81,43 @@
     let nextFooter = null;
 
     while (true) {
-        let selectPane = []
+        let selectPane = [];
 
         if (selectPaneOpen) {
-            let options = [];
+            const options = [];
             pages.forEach(embed => {
                 options.push(new SelectMenuOption({
                     label: embed.title,
                     value: embed.pageId.toString(),
-                    description: embed.description || "",
-                }))
-            })
+                    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([
+        const 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)
+        ])]);
+        const em = new Discord.MessageEmbed(pages[page].embed);
         em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
-        em.setFooter({text: nextFooter ?? ""})
+        em.setFooter({text: nextFooter ?? ""});
         await interaction.editReply({
             embeds: [em],
             components: components.concat(pages[page].components)
         });
-        let i
+        let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break }
-        nextFooter = null
-        i.deferUpdate()
+        } catch(e) { break; }
+        nextFooter = null;
+        i.deferUpdate();
         if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
@@ -130,15 +130,15 @@
             page = parseInt(i.values[0]);
             selectPaneOpen = false;
         } else if (i.component.customId === "clear-all-data") {
-            let confirmation = await new confirmationMessage(interaction)
+            const 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` +
+                    "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)
+                .send(true);
             if (confirmation.cancelled) { break; }
             if (confirmation.success) {
                 client.database.guilds.delete(interaction.guild.id);
@@ -150,25 +150,25 @@
                 continue;
             }
         } else {
-            let em = new Discord.MessageEmbed(pages[page].embed)
-            em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page))
+            const 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
+            return;
         }
     }
-    let em = new Discord.MessageEmbed(pages[page].embed)
-    em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page))
+    const 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) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index d361cf1..d2b05e9 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -8,21 +8,21 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("user")
-    .setDescription("Gives or removes a role from someone")
-    .addUserOption(option => option.setName("user").setDescription("The member to give or remove the role from").setRequired(true))
-    .addRoleOption(option => option.setName("role").setDescription("The role to give or remove").setRequired(true))
-    .addStringOption(option => option.setName("action").setDescription("The action to perform").setRequired(true).addChoices([
-        ["Add", "give"],
-        ["Remove", "remove"]
-    ]))
+        .setName("user")
+        .setDescription("Gives or removes a role from someone")
+        .addUserOption(option => option.setName("user").setDescription("The member to give or remove the role from").setRequired(true))
+        .addRoleOption(option => option.setName("role").setDescription("The role to give or remove").setRequired(true))
+        .addStringOption(option => option.setName("action").setDescription("The action to perform").setRequired(true).addChoices([
+            ["Add", "give"],
+            ["Remove", "remove"]
+        ]));
 
 
 const callback = async (interaction: CommandInteraction): Promise<any>  => {
-    const { renderUser, renderRole } = client.logger
-    let action = interaction.options.getString("action");
+    const { renderUser, renderRole } = client.logger;
+    const action = interaction.options.getString("action");
     // TODO:[Modals] Replace this with a modal
-    let confirmation = await new confirmationMessage(interaction)
+    const confirmation = await new confirmationMessage(interaction)
         .setEmoji("GUILD.ROLES.DELETE")
         .setTitle("Role")
         .setDescription(keyValueList({
@@ -30,16 +30,16 @@
             "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")}?`)
         .setColor("Danger")
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (confirmation.success) {
         try {
-            let member = interaction.options.getMember("user") as GuildMember
-            let role = interaction.options.getRole("role") as Role
+            const member = interaction.options.getMember("user") as GuildMember;
+            const role = interaction.options.getRole("role") as Role;
             if (interaction.options.getString("action") === "give") {
-                member.roles.add(role)
+                member.roles.add(role);
             } else {
-                member.roles.remove(role)
+                member.roles.remove(role);
             }
         } catch (e) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
@@ -47,38 +47,38 @@
                 .setDescription("Something went wrong and the role could not be added")
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
-            ], components: []})
+            ], components: []});
         }
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Role")
             .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
             .setStatus("Success")
             .setEmoji("GUILD.ROLES.CREATE")
-        ], components: []})
+        ], components: []});
     } else {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("GUILD.ROLES.CREATE")
             .setTitle("Role")
-            .setDescription(`No changes were made.`)
+            .setDescription("No changes were made.")
             .setStatus("Danger")
-        ], components: []})
+        ], components: []});
     }
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
+    const member = (interaction.member as GuildMember);
+    const me = (interaction.guild.me as GuildMember);
+    const apply = (interaction.options.getMember("user") as GuildMember);
+    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";
     // 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";
     // Allow role
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/rolemenu.ts b/src/commands/rolemenu.ts
index 39e18f7..1a5f297 100644
--- a/src/commands/rolemenu.ts
+++ b/src/commands/rolemenu.ts
@@ -1,19 +1,19 @@
 import { CommandInteraction } from "discord.js";
 import { SlashCommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
-import { callback as roleMenu } from "../actions/roleMenu.js"
+import { callback as roleMenu } from "../actions/roleMenu.js";
 
 const command = new SlashCommandBuilder()
     .setName("rolemenu")
-    .setDescription("Lets you choose from sets of roles to apply to yourself")
+    .setDescription("Lets you choose from sets of roles to apply to yourself");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     await roleMenu(interaction);
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 70998d5..b70d0a6 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -4,15 +4,15 @@
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) => builder
     .setName("about")
-    .setDescription("Shows info about the server")
+    .setDescription("Shows info about the server");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let guild = interaction.guild as Guild;
-    const { renderUser, renderDelta } = client.logger
+    const guild = interaction.guild as Guild;
+    const { renderUser, renderDelta } = client.logger;
     interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Server Info")
         .setStatus("Success")
@@ -24,26 +24,26 @@
                 "owner": `${renderUser((await guild.fetchOwner()).user)}`,
                 "created": `${renderDelta(guild.createdTimestamp)}`,
                 "emojis": `${guild.emojis.cache.size}` + (guild.emojis.cache.size > 1 ? `\n> ${
-                        guild.emojis.cache.first(10).map((emoji) => `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}>`).join(" ")
-                    }` +
-                    (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : ``) : ""),
+                    guild.emojis.cache.first(10).map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`).join(" ")
+                }` +
+                    (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "") : ""),
                 "icon": `[Discord](${guild.iconURL()})`,
                 "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(/_/, " ", ))}`,
+                "explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " " ))}`,
                 "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
                 "channels": `${guild.channels.cache.size}`,
                 "roles": `${guild.roles.cache.size}`,
-                "members": `${guild.memberCount}`,
+                "members": `${guild.memberCount}`
             })
         )
         .setThumbnail(guild.iconURL({dynamic: true}))
     ], ephemeral: true});
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 23d5c66..7b6b309 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+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";
@@ -11,43 +11,43 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("commands")
-    .setDescription("Links and text shown to a user after a moderator action is performed")
-    .addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"))
+        .setName("commands")
+        .setDescription("Links and text shown to a user after a moderator action is performed")
+        .addRoleOption(o => o.setName("role").setDescription("The role given when a member is muted"));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     let m;
     let clicked = "";
     if (interaction.options.getRole("role")) {
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.ROLES.DELETE")
             .setTitle("Moderation Commands")
             .setDescription(keyValueList({
-                role: `<@&${interaction.options.getRole("role").id}>`,
+                role: `<@&${interaction.options.getRole("role").id}>`
             }))
             .setColor("Danger")
-        .send(true)
+            .send(true);
         if (confirmation.cancelled) return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Moderation Commands")
             .setDescription("No changes were made")
             .setStatus("Success")
             .setEmoji("GUILD.ROLES.CREATE")
-        ]})
+        ]});
         if (confirmation.success) {
             await client.database.guilds.write(interaction.guild.id, {["moderation.mute.role"]: interaction.options.getRole("role").id});
         }
     }
     while (true) {
-        let config = await client.database.guilds.read(interaction.guild.id);
-        let moderation = config.getKey("moderation");
+        const config = await client.database.guilds.read(interaction.guild.id);
+        const moderation = config.getKey("moderation");
         m = await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Moderation Commands")
             .setEmoji("PUNISH.BAN.GREEN")
             .setStatus("Success")
             .setDescription(
                 "These links are shown below the message sent in a user's DM when they are punished.\n\n" +
-                `**Mute Role:** ` + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
+                "**Mute Role:** " + (moderation.mute.role ? `<@&${moderation.mute.role}>` : "*None set*")
             )
         ], components: [new MessageActionRow().addComponents([
             new MessageButton().setLabel("Warn").setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id")).setCustomId("warn").setStyle("SECONDARY"),
@@ -70,19 +70,19 @@
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { return }
+        } catch (e) { return; }
         let chosen = moderation[i.customId] ?? {text: null, url: null};
         if (i.component.customId === "clearMuteRole") {
-            i.deferUpdate()
+            i.deferUpdate();
             if (clicked === "clearMuteRole") {
                 await client.database.guilds.write(interaction.guild.id, {"moderation.mute.role": null });
-            } else { clicked = "clearMuteRole" }
-            continue
-        } else { clicked = "" }
+            } else { clicked = "clearMuteRole"; }
+            continue;
+        } else { clicked = ""; }
         if (i.component.customId === "timeout") {
-            await i.deferUpdate()
+            await i.deferUpdate();
             await client.database.guilds.write(interaction.guild.id, {"moderation.mute.timeout": !moderation.mute.timeout } );
-            continue
+            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()
@@ -101,7 +101,7 @@
                     .setStyle("SHORT")
                     .setValue(chosen.link ?? "")
                 )
-            ))
+            ));
             await interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Moderation Links")
@@ -117,27 +117,27 @@
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => true)
-            } catch (e) { continue }
+                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");
-                let buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
-                let current = chosen;
+                const buttonText = out.fields.getTextInputValue("name");
+                const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
+                const 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 }});
                 }
-            } else { continue }
+            } else { continue; }
         }
     }
-}
+};
 
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/filters.ts b/src/commands/settings/filters.ts
index dfcff99..d35d210 100644
--- a/src/commands/settings/filters.ts
+++ b/src/commands/settings/filters.ts
@@ -1,28 +1,28 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from '../../utils/client.js';
-import confirmationMessage from '../../utils/confirmationMessage.js';
-import generateKeyValueList from '../../utils/generateKeyValueList.js';
-import { ChannelType } from 'discord-api-types';
-import getEmojiByName from '../../utils/getEmojiByName.js';
+import client from "../../utils/client.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import generateKeyValueList from "../../utils/generateKeyValueList.js";
+import { ChannelType } from "discord-api-types";
+import getEmojiByName from "../../utils/getEmojiByName.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("filter")
-    .setDescription("Setting for message filters")
+        .setName("filter")
+        .setDescription("Setting for message filters");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
 
-}
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 2dae74e..edd1c61 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,5 +1,5 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
-import { ChannelType } from 'discord-api-types';
+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";
 import confirmationMessage from "../../../utils/confirmationMessage.js";
@@ -10,76 +10,74 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("attachments")
-    .setDescription("Where attachments should be logged to (Premium only)")
-    .addChannelOption(option => option.setName("channel").setDescription("The channel to log attachments in").addChannelTypes([
-        ChannelType.GuildNews, ChannelType.GuildText
-    ]).setRequired(false))
+        .setName("attachments")
+        .setDescription("Where attachments should be logged to (Premium only)")
+        .addChannelOption(option => option.setName("channel").setDescription("The channel to log attachments in").addChannelTypes([
+            ChannelType.GuildNews, ChannelType.GuildText
+        ]).setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
     m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getChannel("channel")) {
-        let channel
+        let channel;
         try {
-            channel = interaction.options.getChannel("channel")
+            channel = interaction.options.getChannel("channel");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.TEXT.DELETE")
                 .setTitle("Attachment Log Channel")
                 .setDescription("The channel you provided is not a valid channel")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
-        channel = channel as Discord.TextChannel
+        channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Attachment Log Channel")
-                .setDescription(`You must choose a channel in this server`)
+                .setDescription("You must choose a channel in this server")
                 .setStatus("Danger")
                 .setEmoji("CHANNEL.TEXT.DELETE")
             ]});
         }
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Attachment Log Channel")
             .setDescription(
-                `This will be the channel all attachments will be sent to.\n\n` +
+                "This will be the channel all attachments will be sent to.\n\n" +
                 `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
             )
             .setColor("Warning")
             .setInverted(true)
-        .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"logging.attachments.channel": channel.id})
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
-                try {
-                    let data = {
-                        meta:{
-                            type: 'attachmentChannelUpdate',
-                            displayName: 'Attachment Log Channel Updated',
-                            calculateType: 'nucleusSettingsUpdated',
-                            color: NucleusColors.yellow,
-                            emoji: "CHANNEL.TEXT.EDIT",
-                            timestamp: new Date().getTime()
-                        },
-                        list: {
-                            memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                            changedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                            channel: entry(channel.id, renderChannel(channel)),
-                        },
-                        hidden: {
-                            guild: interaction.guild.id
-                        }
+                await client.database.guilds.write(interaction.guild.id, {"logging.attachments.channel": channel.id});
+                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                const data = {
+                    meta:{
+                        type: "attachmentChannelUpdate",
+                        displayName: "Attachment Log Channel Updated",
+                        calculateType: "nucleusSettingsUpdated",
+                        color: NucleusColors.yellow,
+                        emoji: "CHANNEL.TEXT.EDIT",
+                        timestamp: new Date().getTime()
+                    },
+                    list: {
+                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        channel: entry(channel.id, renderChannel(channel))
+                    },
+                    hidden: {
+                        guild: interaction.guild.id
                     }
-                    log(data);
-                } catch {}
+                };
+                log(data);
             } catch (e) {
                 return interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Attachment Log Channel")
-                    .setDescription(`Something went wrong and the attachment log channel could not be set`)
+                    .setDescription("Something went wrong and the attachment log channel could not be set")
                     .setStatus("Danger")
                     .setEmoji("CHANNEL.TEXT.DELETE")
                 ], components: []});
@@ -87,14 +85,14 @@
         } else {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Attachment Log Channel")
-                .setDescription(`No changes were made`)
+                .setDescription("No changes were made")
                 .setStatus("Success")
                 .setEmoji("CHANNEL.TEXT.CREATE")
             ], components: []});
         }
     }
     let clicks = 0;
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const data = await client.database.guilds.read(interaction.guild.id);
     let channel = data.logging.staff.channel;
     while (true) {
         await interaction.editReply({embeds: [new EmojiEmbed()
@@ -115,17 +113,17 @@
         let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break }
-        i.deferUpdate()
+        } catch(e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"])
+                await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"]);
                 channel = undefined;
             }
         } else {
-            break
+            break;
         }
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
@@ -141,13 +139,13 @@
         .setStyle("SECONDARY")
         .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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 4030108..da0d156 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,5 +1,5 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
-import { ChannelType } from 'discord-api-types';
+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";
 import confirmationMessage from "../../../utils/confirmationMessage.js";
@@ -10,74 +10,72 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("channel")
-    .setDescription("Sets or shows the log channel")
-    .addChannelOption(option => option.setName("channel").setDescription("The channel to set the log channel to").addChannelTypes([
-        ChannelType.GuildNews, ChannelType.GuildText
-    ]))
+        .setName("channel")
+        .setDescription("Sets or shows the log channel")
+        .addChannelOption(option => option.setName("channel").setDescription("The channel to set the log channel to").addChannelTypes([
+            ChannelType.GuildNews, ChannelType.GuildText
+        ]));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
     m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getChannel("channel")) {
-        let channel
+        let channel;
         try {
-            channel = interaction.options.getChannel("channel")
+            channel = interaction.options.getChannel("channel");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.TEXT.DELETE")
                 .setTitle("Log Channel")
                 .setDescription("The channel you provided is not a valid channel")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
-        channel = channel as Discord.TextChannel
+        channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Log Channel")
-                .setDescription(`You must choose a channel in this server`)
+                .setDescription("You must choose a channel in this server")
                 .setStatus("Danger")
                 .setEmoji("CHANNEL.TEXT.DELETE")
             ]});
         }
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Log Channel")
             .setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`)
             .setColor("Warning")
             .setInverted(true)
-        .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id})
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
-                try {
-                    let data = {
-                        meta:{
-                            type: 'logChannelUpdate',
-                            displayName: 'Log Channel Changed',
-                            calculateType: 'nucleusSettingsUpdated',
-                            color: NucleusColors.yellow,
-                            emoji: "CHANNEL.TEXT.EDIT",
-                            timestamp: new Date().getTime()
-                        },
-                        list: {
-                            memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                            changedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                            channel: entry(channel.id, renderChannel(channel)),
-                        },
-                        hidden: {
-                            guild: channel.guild.id
-                        }
+                await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id});
+                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                const data = {
+                    meta:{
+                        type: "logChannelUpdate",
+                        displayName: "Log Channel Changed",
+                        calculateType: "nucleusSettingsUpdated",
+                        color: NucleusColors.yellow,
+                        emoji: "CHANNEL.TEXT.EDIT",
+                        timestamp: new Date().getTime()
+                    },
+                    list: {
+                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        channel: entry(channel.id, renderChannel(channel))
+                    },
+                    hidden: {
+                        guild: channel.guild.id
                     }
-                    log(data);
-                } catch {}
+                };
+                log(data);
             } catch (e) {
-                console.log(e)
+                console.log(e);
                 return interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Log Channel")
-                    .setDescription(`Something went wrong and the log channel could not be set`)
+                    .setDescription("Something went wrong and the log channel could not be set")
                     .setStatus("Danger")
                     .setEmoji("CHANNEL.TEXT.DELETE")
                 ], components: []});
@@ -85,14 +83,14 @@
         } else {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Log Channel")
-                .setDescription(`No changes were made`)
+                .setDescription("No changes were made")
                 .setStatus("Success")
                 .setEmoji("CHANNEL.TEXT.CREATE")
             ], components: []});
         }
     }
     let clicks = 0;
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const data = await client.database.guilds.read(interaction.guild.id);
     let channel = data.logging.logs.channel;
     while (true) {
         await interaction.editReply({embeds: [new EmojiEmbed()
@@ -110,17 +108,17 @@
         let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break }
-        i.deferUpdate()
+        } catch(e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"])
+                await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"]);
                 channel = undefined;
             }
         } else {
-            break
+            break;
         }
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
@@ -136,13 +134,13 @@
         .setStyle("SECONDARY")
         .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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index ef303cb..88386c4 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,9 +1,9 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
-import client from '../../../utils/client.js';
+import client from "../../../utils/client.js";
 import { toHexArray, toHexInteger } from "../../../utils/calculate.js";
 
 
@@ -27,20 +27,20 @@
     "guildMemberVerify": "Member runs verify",
     "autoModeratorDeleted": "Messages auto deleted by Nucleus",
     "nucleusSettingsUpdated": "Nucleus' settings updated by a moderator",
-    "ticketUpdate": "Tickets created or deleted",
-}
+    "ticketUpdate": "Tickets created or deleted"
+};
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("events")
-    .setDescription("Sets what events should be logged")
+        .setName("events")
+        .setDescription("Sets what events should be logged");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
     let m;
     while (true) {
-        let config = await client.database.guilds.read(interaction.guild.id)
-        let converted = toHexArray(config.logging.logs.toLog)
+        const config = await client.database.guilds.read(interaction.guild.id);
+        const converted = toHexArray(config.logging.logs.toLog);
         m = await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Logging Events")
             .setDescription("Below are the events being logged in the server. You can toggle them on and off in the dropdown")
@@ -68,25 +68,25 @@
                     .setStyle("DANGER")
                     .setCustomId("none")
             ])
-        ]})
+        ]});
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
         } catch (e) {
-            break
+            break;
         }
-        i.deferUpdate()
+        i.deferUpdate();
         if (i.customId === "logs") {
-            let selected = i.values;
-            let newLogs = toHexInteger(selected.map(e => Object.keys(logs)[parseInt(e)]))
-            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs})
+            const selected = i.values;
+            const newLogs = toHexInteger(selected.map(e => Object.keys(logs)[parseInt(e)]));
+            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
         } else if (i.customId === "all") {
-            let newLogs = toHexInteger(Object.keys(logs).map(e => e))
-            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs})
+            const newLogs = toHexInteger(Object.keys(logs).map(e => e));
+            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
         } else if (i.customId === "none") {
-            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": 0})
+            await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": 0});
         } else {
-            break
+            break;
         }
     }
     m = await interaction.editReply({embeds: [new EmojiEmbed()
@@ -95,14 +95,14 @@
         .setFooter({text: "Message timed out"})
         .setStatus("Success")
         .setEmoji("CHANNEL.TEXT.CREATE")
-    ]})
-}
+    ]});
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 5867338..2f0c819 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,85 +1,85 @@
-import { LoadingEmbed } from './../../../utils/defaultEmbeds.js';
-import { ChannelType } from 'discord-api-types';
+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";
 import confirmationMessage from "../../../utils/confirmationMessage.js";
 import getEmojiByName from "../../../utils/getEmojiByName.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { WrappedCheck } from "jshaiku";
 import client from "../../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("staff")
-    .setDescription("Settings for the staff notifications channel")
-    .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
-        ChannelType.GuildNews, ChannelType.GuildText
-    ]).setRequired(false))
+        .setName("staff")
+        .setDescription("Settings for the staff notifications channel")
+        .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
+            ChannelType.GuildNews, ChannelType.GuildText
+        ]).setRequired(false));
 
-const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let m;
-    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (interaction: CommandInteraction): Promise<unknown | void> => {
+    if (!interaction.guild) return;
+    const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message<boolean>;
     if (interaction.options.getChannel("channel")) {
-        let channel
+        let channel;
         try {
-            channel = interaction.options.getChannel("channel")
+            channel = interaction.options.getChannel("channel");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.TEXT.DELETE")
                 .setTitle("Staff Notifications Channel")
                 .setDescription("The channel you provided is not a valid channel")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
-        channel = channel as Discord.TextChannel
+        channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Staff Notifications Channel")
-                .setDescription(`You must choose a channel in this server`)
+                .setDescription("You must choose a channel in this server")
                 .setStatus("Danger")
                 .setEmoji("CHANNEL.TEXT.DELETE")
             ]});
         }
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Staff Notifications Channel")
             .setDescription(
-                `This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n` +
+                "This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n" +
                 `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
             )
             .setColor("Warning")
             .setInverted(true)
-        .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id})
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
-                try {
-                    let data = {
-                        meta:{
-                            type: 'staffChannelUpdate',
-                            displayName: 'Staff Notifications Channel Updated',
-                            calculateType: 'nucleusSettingsUpdated',
-                            color: NucleusColors.yellow,
-                            emoji: "CHANNEL.TEXT.EDIT",
-                            timestamp: new Date().getTime()
-                        },
-                        list: {
-                            memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                            changedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                            channel: entry(channel.id, renderChannel(channel)),
-                        },
-                        hidden: {
-                            guild: interaction.guild.id
-                        }
+                await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id});
+                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                const data = {
+                    meta:{
+                        type: "staffChannelUpdate",
+                        displayName: "Staff Notifications Channel Updated",
+                        calculateType: "nucleusSettingsUpdated",
+                        color: NucleusColors.yellow,
+                        emoji: "CHANNEL.TEXT.EDIT",
+                        timestamp: new Date().getTime()
+                    },
+                    list: {
+                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        channel: entry(channel.id, renderChannel(channel))
+                    },
+                    hidden: {
+                        guild: interaction.guild.id
                     }
-                    log(data);
-                } catch {}
+                };
+                log(data);
             } catch (e) {
                 return interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Staff Notifications Channel")
-                    .setDescription(`Something went wrong and the staff notifications channel could not be set`)
+                    .setDescription("Something went wrong and the staff notifications channel could not be set")
                     .setStatus("Danger")
                     .setEmoji("CHANNEL.TEXT.DELETE")
                 ], components: []});
@@ -87,14 +87,14 @@
         } else {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Staff Notifications Channel")
-                .setDescription(`No changes were made`)
+                .setDescription("No changes were made")
                 .setStatus("Success")
                 .setEmoji("CHANNEL.TEXT.CREATE")
             ], components: []});
         }
     }
     let clicks = 0;
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const data = await client.database.guilds.read(interaction.guild.id);
     let channel = data.logging.staff.channel;
     while (true) {
         await interaction.editReply({embeds: [new EmojiEmbed()
@@ -112,17 +112,17 @@
         let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break }
-        i.deferUpdate()
-        if (i.component.customId === "clear") {
+        } catch(e) { break; }
+        i.deferUpdate();
+        if ((i.component as MessageButton).customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"])
+                await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"]);
                 channel = undefined;
             }
         } else {
-            break
+            break;
         }
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
@@ -138,13 +138,13 @@
         .setStyle("SECONDARY")
         .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"
+const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 891b6f1..9a4ceb0 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -1,25 +1,23 @@
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
-import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import confirmationMessage from "../../utils/confirmationMessage.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
+import Discord, { CommandInteraction } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
-import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("rolemenu")
-    .setDescription("rolemenu")// TODO
-    .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying")) // TODO
+        .setName("rolemenu")
+        .setDescription("rolemenu")// TODO
+        .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying")); // FIXME FOR FUCK SAKE
 
-const callback = async (interaction: CommandInteraction): Promise<any> => {
-}
+const callback = async (interaction: CommandInteraction): Promise<void> => {
+    console.log("we changed the charger again because fuck you");
+    await interaction.reply("You're mum");
+};
 
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    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"
+const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_ROLES")) throw "You must have the *Manage Roles* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 10fba6b..4d61496 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -1,23 +1,23 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageSelectMenu } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import client from "../../utils/client.js";
-import convertCurlyBracketString from '../../utils/convertCurlyBracketString.js';
+import convertCurlyBracketString from "../../utils/convertCurlyBracketString.js";
 import {callback as statsChannelAddCallback} from "../../reflex/statsChannelUpdate.js";
-import singleNotify from '../../utils/singleNotify.js';
+import singleNotify from "../../utils/singleNotify.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("stats")
-    .setDescription("Controls channels which update when someone joins or leaves the server")
-    .addChannelOption(option => option.setName("channel").setDescription("The channel to modify"))
-    .addStringOption(option => option.setName("name").setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}").setAutocomplete(true))
+        .setName("stats")
+        .setDescription("Controls channels which update when someone joins or leaves the server")
+        .addChannelOption(option => option.setName("channel").setDescription("The channel to modify"))
+        .addStringOption(option => option.setName("name").setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}").setAutocomplete(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    singleNotify("statsChannelDeleted", interaction.guild.id, true)
+    singleNotify("statsChannelDeleted", interaction.guild.id, true);
     let m;
     m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     let config = await client.database.guilds.read(interaction.guild.id);
@@ -29,72 +29,70 @@
                 .setTitle("Stats Channel")
                 .setDescription("You can only have 25 stats channels in a server")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
         try {
-            channel = interaction.options.getChannel("channel")
+            channel = interaction.options.getChannel("channel");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("CHANNEL.TEXT.DELETE")
                 .setTitle("Stats Channel")
                 .setDescription("The channel you provided is not a valid channel")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
-        channel = channel as Discord.TextChannel
+        channel = channel as Discord.TextChannel;
         if (channel.guild.id !== interaction.guild.id) {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Stats Channel")
-                .setDescription(`You must choose a channel in this server`)
+                .setDescription("You must choose a channel in this server")
                 .setStatus("Danger")
                 .setEmoji("CHANNEL.TEXT.DELETE")
             ]});
         }
-        let newName = await convertCurlyBracketString(interaction.options.getString("name"), null, null, interaction.guild.name, interaction.guild.members)
+        let newName = await convertCurlyBracketString(interaction.options.getString("name"), null, null, interaction.guild.name, interaction.guild.members);
         if (interaction.options.getChannel("channel").type === "GUILD_TEXT") {
-            newName = newName.toLowerCase().replace(/[\s]/g, "-")
+            newName = newName.toLowerCase().replace(/[\s]/g, "-");
         }
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("CHANNEL.TEXT.EDIT")
             .setTitle("Stats Channel")
             .setDescription(`Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(/^ +| $/g, "")}*`)
             .setColor("Warning")
             .setInverted(true)
-        .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                let name = interaction.options.getString("name")
-                let channel = interaction.options.getChannel("channel")
+                const name = interaction.options.getString("name");
+                const channel = interaction.options.getChannel("channel");
                 await client.database.guilds.write(interaction.guild.id, {[`stats.${channel.id}`]: {name: name, enabled: true}});
-                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger
-                try {
-                    let data = {
-                        meta:{
-                            type: 'statsChannelUpdate',
-                            displayName: 'Stats Channel Updated',
-                            calculateType: 'nucleusSettingsUpdated',
-                            color: NucleusColors.yellow,
-                            emoji: "CHANNEL.TEXT.EDIT",
-                            timestamp: new Date().getTime()
-                        },
-                        list: {
-                            memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                            changedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                            channel: entry(channel.id, renderChannel(channel)),
-                            name: entry(interaction.options.getString("name"), `\`${interaction.options.getString("name")}\``)
-                        },
-                        hidden: {
-                            guild: interaction.guild.id
-                        }
+                const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+                const data = {
+                    meta:{
+                        type: "statsChannelUpdate",
+                        displayName: "Stats Channel Updated",
+                        calculateType: "nucleusSettingsUpdated",
+                        color: NucleusColors.yellow,
+                        emoji: "CHANNEL.TEXT.EDIT",
+                        timestamp: new Date().getTime()
+                    },
+                    list: {
+                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        channel: entry(channel.id, renderChannel(channel)),
+                        name: entry(interaction.options.getString("name"), `\`${interaction.options.getString("name")}\``)
+                    },
+                    hidden: {
+                        guild: interaction.guild.id
                     }
-                    log(data);
-                } catch {}
+                };
+                log(data);
             } catch (e) {
-                console.log(e)
+                console.log(e);
                 return interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Stats Channel")
-                    .setDescription(`Something went wrong and the stats channel could not be set`)
+                    .setDescription("Something went wrong and the stats channel could not be set")
                     .setStatus("Danger")
                     .setEmoji("CHANNEL.TEXT.DELETE")
                 ], components: []});
@@ -102,7 +100,7 @@
         } else {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Stats Channel")
-                .setDescription(`No changes were made`)
+                .setDescription("No changes were made")
                 .setStatus("Success")
                 .setEmoji("CHANNEL.TEXT.CREATE")
             ], components: []});
@@ -111,11 +109,11 @@
     }
     while (true) {
         config = await client.database.guilds.read(interaction.guild.id);
-        let stats = config.getKey("stats")
-        let selectMenu = new MessageSelectMenu()
+        const stats = config.getKey("stats");
+        const selectMenu = new MessageSelectMenu()
             .setCustomId("remove")
             .setMinValues(1)
-            .setMaxValues(Math.max(1, Object.keys(stats).length))
+            .setMaxValues(Math.max(1, Object.keys(stats).length));
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Stats Channel")
             .setDescription("The following channels update when someone joins or leaves the server. You can select a channel to remove it from the list.")
@@ -126,30 +124,30 @@
                 selectMenu.setPlaceholder("Select a stats channel to remove, stopping it updating").addOptions(Object.keys(stats).map(key => ({
                     label: interaction.guild.channels.cache.get(key).name,
                     value: key,
-                    description: `${stats[key].name}`,
+                    description: `${stats[key].name}`
                 })))
             ] : [selectMenu.setPlaceholder("The server has no stats channels").setDisabled(true).setOptions([
                 {label: "*Placeholder*", value: "placeholder", description: "No stats channels"}
             ])])
-        ]})
+        ]});
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { break }
-        i.deferUpdate()
+        } catch (e) { break; }
+        i.deferUpdate();
         if (i.customId === "remove") {
-            let toRemove = i.values;
+            const toRemove = i.values;
             await client.database.guilds.write(interaction.guild.id, null, toRemove.map(k => `stats.${k}`));
         }
     }
     await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let member = (interaction.member as Discord.GuildMember)
-    if (!member.permissions.has("MANAGE_CHANNELS")) throw "You must have the *Manage Channels* permission to use this command"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_CHANNELS")) throw "You must have the *Manage Channels* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 8ebcf30..3d1901b 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,14 +1,14 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
 import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
-import { ChannelType } from 'discord-api-types';
+import { ChannelType } from "discord-api-types";
 import client from "../../utils/client.js";
 import { toHexInteger, toHexArray, tickets as ticketTypes } from "../../utils/calculate.js";
-import { capitalize } from '../../utils/generateKeyValueList.js';
+import { capitalize } from "../../utils/generateKeyValueList.js";
 import { modalInteractionCollector } from "../../utils/dualCollector.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) => builder
@@ -18,24 +18,24 @@
         .addChoices([["Yes", "yes"], ["No", "no"]]))
     .addChannelOption(option => option.setName("category").setDescription("The category where tickets are created").addChannelType(ChannelType.GuildCategory).setRequired(false))
     .addNumberOption(option => option.setName("maxticketsperuser").setDescription("The maximum amount of tickets a user can create | Default: 5").setRequired(false).setMinValue(1))
-    .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false))
+    .addRoleOption(option => option.setName("supportrole").setDescription("This role will have view access to all tickets and will be pinged when a ticket is created").setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
-    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
-    let options = {
+    m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+    const options = {
         enabled: interaction.options.getString("enabled") as string | boolean,
         category: interaction.options.getChannel("category"),
         maxtickets: interaction.options.getNumber("maxticketsperuser"),
         supportping: interaction.options.getRole("supportrole")
-    }
-    console.log(m)
+    };
+    console.log(m);
     if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
         options.enabled = options.enabled === "yes" ? true : false;
         if (options.category) {
-            let channel
+            let channel;
             try {
-                channel = interaction.guild.channels.cache.get(options.category.id)
+                channel = interaction.guild.channels.cache.get(options.category.id);
             } catch {
                 return await interaction.editReply({
                     embeds: [new EmojiEmbed()
@@ -44,13 +44,13 @@
                         .setDescription("The channel you provided is not a valid category")
                         .setStatus("Danger")
                     ]
-                })
+                });
             }
-            channel = channel as Discord.CategoryChannel
+            channel = channel as Discord.CategoryChannel;
             if (channel.guild.id !== interaction.guild.id) return interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets > Category")
-                    .setDescription(`You must choose a category in this server`)
+                    .setDescription("You must choose a category in this server")
                     .setStatus("Danger")
                     .setEmoji("CHANNEL.TEXT.DELETE")
                 ]
@@ -60,16 +60,16 @@
             if (options.maxtickets < 1) return interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets > Max Tickets")
-                    .setDescription(`You must choose a number greater than 0`)
+                    .setDescription("You must choose a number greater than 0")
                     .setStatus("Danger")
                     .setEmoji("CHANNEL.TEXT.DELETE")
                 ]
             });
         }
-        let role
+        let role;
         if (options.supportping) {
             try {
-                role = interaction.guild.roles.cache.get(options.supportping.id)
+                role = interaction.guild.roles.cache.get(options.supportping.id);
             } catch {
                 return await interaction.editReply({
                     embeds: [new EmojiEmbed()
@@ -78,20 +78,20 @@
                         .setDescription("The role you provided is not a valid role")
                         .setStatus("Danger")
                     ]
-                })
+                });
             }
-            role = role as Discord.Role
+            role = role as Discord.Role;
             if (role.guild.id !== interaction.guild.id) return interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets > Support Ping")
-                    .setDescription(`You must choose a role in this server`)
+                    .setDescription("You must choose a role in this server")
                     .setStatus("Danger")
                     .setEmoji("GUILD.ROLE.DELETE")
                 ]
             });
         }
 
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.TICKET.ARCHIVED")
             .setTitle("Tickets")
             .setDescription(
@@ -99,26 +99,26 @@
                 (options.maxtickets ? `**Max Tickets:** ${options.maxtickets}\n` : "") +
                 (options.supportping ? `**Support Ping:** ${options.supportping.name}\n` : "") +
                 (options.enabled !== null ? `**Enabled:** ${options.enabled ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-                    }\n` : "") +
-                `\nAre you sure you want to apply these settings?`
+                }\n` : "") +
+                "\nAre you sure you want to apply these settings?"
             )
             .setColor("Warning")
             .setInverted(true)
-            .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
-            let toUpdate = {}
-            if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled
-            if (options.category) toUpdate["tickets.category"] = options.category.id
-            if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets
-            if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id
+            const toUpdate = {};
+            if (options.enabled !== null) toUpdate["tickets.enabled"] = options.enabled;
+            if (options.category) toUpdate["tickets.category"] = options.category.id;
+            if (options.maxtickets) toUpdate["tickets.maxTickets"] = options.maxtickets;
+            if (options.supportping) toUpdate["tickets.supportRole"] = options.supportping.id;
             try {
-                await client.database.guilds.write(interaction.guild.id, toUpdate)
+                await client.database.guilds.write(interaction.guild.id, toUpdate);
             } catch (e) {
                 return interaction.editReply({
                     embeds: [new EmojiEmbed()
                         .setTitle("Tickets")
-                        .setDescription(`Something went wrong and the staff notifications channel could not be set`)
+                        .setDescription("Something went wrong and the staff notifications channel could not be set")
                         .setStatus("Danger")
                         .setEmoji("GUILD.TICKET.DELETE")
                     ], components: []
@@ -128,7 +128,7 @@
             return interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets")
-                    .setDescription(`No changes were made`)
+                    .setDescription("No changes were made")
                     .setStatus("Success")
                     .setEmoji("GUILD.TICKET.OPEN")
                 ], components: []
@@ -136,7 +136,7 @@
         }
     }
     let data = await client.database.guilds.read(interaction.guild.id);
-    data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i)
+    data.tickets.customTypes = (data.tickets.customTypes || []).filter((v, i, a) => a.indexOf(v) === i);
     let lastClicked = "";
     let embed;
     data = {
@@ -147,7 +147,7 @@
         useCustom: data.tickets.useCustom,
         types: data.tickets.types,
         customTypes: data.tickets.customTypes
-    }
+    };
     while (true) {
         embed = new EmojiEmbed()
             .setTitle("Tickets")
@@ -161,7 +161,7 @@
                 `${getEmojiByName("TICKETS.REPORT")} *Indicates a setting stopping tickets from being used*`
             )
             .setStatus("Success")
-            .setEmoji("GUILD.TICKET.OPEN")
+            .setEmoji("GUILD.TICKET.OPEN");
         m = await interaction.editReply({
             embeds: [embed], components: [new MessageActionRow().addComponents([
                 new MessageButton()
@@ -186,7 +186,7 @@
                     .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")
@@ -197,40 +197,40 @@
                     .setLabel("Add create ticket button")
                     .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
                     .setStyle("PRIMARY")
-                    .setCustomId("send"),
+                    .setCustomId("send")
             ])]
         });
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { break }
-        i.deferUpdate()
+        } catch (e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "clearCategory") {
             if (lastClicked === "cat") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"])
+                await client.database.guilds.write(interaction.guild.id, null, ["tickets.category"]);
                 data.category = undefined;
             } else lastClicked = "cat";
         } else if (i.component.customId === "clearMaxTickets") {
             if (lastClicked === "max") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"])
+                await client.database.guilds.write(interaction.guild.id, null, ["tickets.maxTickets"]);
                 data.maxTickets = 5;
             } else lastClicked = "max";
         } else if (i.component.customId === "clearSupportPing") {
             if (lastClicked === "sup") {
                 lastClicked = "";
-                await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"])
+                await client.database.guilds.write(interaction.guild.id, null, ["tickets.supportRole"]);
                 data.supportRole = undefined;
             } else lastClicked = "sup";
         } else if (i.component.customId === "send") {
             const ticketMessages = [
                 {label: "Create ticket", description: "Click the button below to create a ticket"},
                 {label: "Issues, questions or feedback?", description: "Click below to open a ticket and get help from our staff team"},
-                {label: "Contact Us", description: "Click the button below to speak to us privately"},
-            ]
+                {label: "Contact Us", description: "Click the button below to speak to us privately"}
+            ];
             while (true) {
-                let enabled = data.enabled && data.category !== null;
+                const enabled = data.enabled && data.category !== null;
                 await interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Ticket Button")
                     .setDescription("Select a message template to send in this channel")
@@ -240,8 +240,8 @@
                 ], components: [
                     new MessageActionRow().addComponents([
                         new MessageSelectMenu().setOptions(ticketMessages.map((t: {label: string, description: string, value?: string}, index) => {
-                            t.value = index.toString(); return t as {value: string, label: string, description: string}
-                        })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template"),
+                            t.value = index.toString(); return t as {value: string, label: string, description: string};
+                        })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
                     ]),
                     new MessageActionRow().addComponents([
                         new MessageButton()
@@ -263,9 +263,9 @@
                 let i;
                 try {
                     i = await m.awaitMessageComponent({time: 300000});
-                } catch(e) { break }
+                } catch(e) { break; }
                 if (i.component.customId === "template") {
-                    i.deferUpdate()
+                    i.deferUpdate();
                     await interaction.channel.send({embeds: [new EmojiEmbed()
                         .setTitle(ticketMessages[parseInt(i.values[0])].label)
                         .setDescription(ticketMessages[parseInt(i.values[0])].description)
@@ -277,18 +277,18 @@
                         .setStyle("SUCCESS")
                         .setCustomId("createticket")
                     ])]});
-                    break
+                    break;
                 } else if (i.component.customId === "blank") {
-                    i.deferUpdate()
+                    i.deferUpdate();
                     await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
                         .setLabel("Create Ticket")
                         .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
                         .setStyle("SUCCESS")
                         .setCustomId("createticket")
                     ])]});
-                    break
+                    break;
                 } else if (i.component.customId === "custom") {
-                    await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Enter embed details`).addComponents(
+                    await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
                         new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
                             .setCustomId("title")
                             .setLabel("Title")
@@ -303,7 +303,7 @@
                             .setRequired(true)
                             .setStyle("PARAGRAPH")
                         )
-                    ))
+                    ));
                     await interaction.editReply({
                         embeds: [new EmojiEmbed()
                             .setTitle("Ticket Button")
@@ -319,11 +319,11 @@
                     });
                     let out;
                     try {
-                        out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
-                    } catch (e) { break }
+                        out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
+                    } catch (e) { break; }
                     if (out.fields) {
-                        let title = out.fields.getTextInputValue("title");
-                        let description = out.fields.getTextInputValue("description");
+                        const title = out.fields.getTextInputValue("title");
+                        const description = out.fields.getTextInputValue("description");
                         await interaction.channel.send({embeds: [new EmojiEmbed()
                             .setTitle(title)
                             .setDescription(description)
@@ -335,26 +335,26 @@
                             .setStyle("SUCCESS")
                             .setCustomId("createticket")
                         ])]});
-                        break
-                    } else { continue }
+                        break;
+                    } else { continue; }
                 }
             }
         } else if (i.component.customId === "enabled") {
-            await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled })
+            await client.database.guilds.write(interaction.guild.id, { "tickets.enabled": !data.enabled });
             data.enabled = !data.enabled;
         } else if (i.component.customId === "manageTypes") {
             data = await manageTypes(interaction, data, m);
         } else {
-            break
+            break;
         }
     }
     await interaction.editReply({ embeds: [embed.setFooter({ text: "Message closed" })], components: [] });
-}
+};
 
 async function manageTypes(interaction, data, m) {
     while (true) {
         if (data.useCustom) {
-            let customTypes = data.customTypes;
+            const customTypes = data.customTypes;
             await interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets > Types")
@@ -393,29 +393,29 @@
                         new MessageButton()
                             .setLabel("Switch to default types")
                             .setStyle("SECONDARY")
-                            .setCustomId("switchToDefault"),
+                            .setCustomId("switchToDefault")
                     ])
                 ])
             });
         } else {
-            let inUse = toHexArray(data.types, ticketTypes)
-            let options = [];
+            const inUse = toHexArray(data.types, ticketTypes);
+            const options = [];
             ticketTypes.forEach(type => {
                 options.push(new SelectMenuOption({
                     label: capitalize(type),
                     value: type,
                     emoji: client.emojis.cache.get(getEmojiByName(`TICKETS.${type.toUpperCase()}`, "id")),
                     default: inUse.includes(type)
-                }))
-            })
-            let selectPane = new MessageActionRow().addComponents([
+                }));
+            });
+            const selectPane = new MessageActionRow().addComponents([
                 new Discord.MessageSelectMenu()
                     .addOptions(options)
                     .setCustomId("types")
                     .setMaxValues(ticketTypes.length)
                     .setMinValues(1)
                     .setPlaceholder("Select types to use")
-            ])
+            ]);
             await interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets > Types")
@@ -437,7 +437,7 @@
                         new MessageButton()
                             .setLabel("Switch to custom types")
                             .setStyle("SECONDARY")
-                            .setCustomId("switchToCustom"),
+                            .setCustomId("switchToCustom")
                     ])
                 ]
             });
@@ -445,20 +445,20 @@
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
-        } catch (e) { break }
+        } catch (e) { break; }
         if (i.component.customId === "types") {
-            i.deferUpdate()
-            let types = toHexInteger(i.values, ticketTypes);
-            await client.database.guilds.write(interaction.guild.id, { "tickets.types": types })
+            i.deferUpdate();
+            const 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") {
-            i.deferUpdate()
-            let types = i.values
+            i.deferUpdate();
+            const types = i.values;
             let customTypes = data.customTypes;
             if (customTypes) {
                 customTypes = customTypes.filter((t) => !types.includes(t));
                 customTypes = customTypes.length > 0 ? customTypes : null;
-                await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes })
+                await client.database.guilds.write(interaction.guild.id, { "tickets.customTypes": customTypes });
                 data.customTypes = customTypes;
             }
         } else if (i.component.customId === "addType") {
@@ -472,7 +472,7 @@
                     .setRequired(true)
                     .setStyle("SHORT")
                 )
-            ))
+            ));
             await interaction.editReply({
                 embeds: [new EmojiEmbed()
                     .setTitle("Tickets > Types")
@@ -488,42 +488,42 @@
             });
             let out;
             try {
-                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType")
-            } catch (e) { continue }
+                out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "addType");
+            } catch (e) { continue; }
             if (out.fields) {
                 let toAdd = out.fields.getTextInputValue("type");
-                if (!toAdd) { continue }
-                toAdd = toAdd.substring(0, 80)
+                if (!toAdd) { continue; }
+                toAdd = toAdd.substring(0, 80);
                 try {
-                    await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd)
-                } catch { continue }
+                    await client.database.guilds.append(interaction.guild.id, "tickets.customTypes", toAdd);
+                } catch { continue; }
                 data.customTypes = data.customTypes || [];
                 if (!data.customTypes.includes(toAdd)) {
                     data.customTypes.push(toAdd);
                 }
-            } else { continue }
+            } else { continue; }
         } else if (i.component.customId === "switchToDefault") {
-            i.deferUpdate()
-            await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, [])
+            i.deferUpdate();
+            await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": false }, []);
             data.useCustom = false;
         } else if (i.component.customId === "switchToCustom") {
-            i.deferUpdate()
-            await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, [])
+            i.deferUpdate();
+            await client.database.guilds.write(interaction.guild.id, { "tickets.useCustom": true }, []);
             data.useCustom = true;
         } else {
-            i.deferUpdate()
-            break
+            i.deferUpdate();
+            break;
         }
     }
-    return data
+    return data;
 }
 
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index a77f2f4..c100d05 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, Emoji, MessageActionRow, MessageButton, MessageSelectMenu, TextInputComponent } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -6,76 +6,74 @@
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import client from "../../utils/client.js";
-import { modalInteractionCollector } from '../../utils/dualCollector.js';
+import { modalInteractionCollector } from "../../utils/dualCollector.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("verify")
-    .setDescription("Manage the role given after typing /verify")
-    .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying").setRequired(false))
+        .setName("verify")
+        .setDescription("Manage the role given after typing /verify")
+        .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying").setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     let m;
     m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
     if (interaction.options.getRole("role")) {
-        let role
+        let role;
         try {
-            role = interaction.options.getRole("role")
+            role = interaction.options.getRole("role");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("GUILD.ROLES.DELETE")
                 .setTitle("Verify Role")
                 .setDescription("The role you provided is not a valid role")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
-        role = role as Discord.Role
+        role = role as Discord.Role;
         if (role.guild.id !== interaction.guild.id) {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify Role")
-                .setDescription(`You must choose a role in this server`)
+                .setDescription("You must choose a role in this server")
                 .setStatus("Danger")
                 .setEmoji("GUILD.ROLES.DELETE")
             ]});
         }
-        let confirmation = await new confirmationMessage(interaction)
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.ROLES.EDIT")
             .setTitle("Verify Role")
             .setDescription(`Are you sure you want to set the verify role to <@&${role.id}>?`)
             .setColor("Warning")
             .setInverted(true)
-        .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
                 await client.database.guilds.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
-                const { log, NucleusColors, entry, renderUser, renderRole } = client.logger
-                try {
-                    let data = {
-                        meta:{
-                            type: 'verifyRoleChanged',
-                            displayName: 'Verify Role Changed',
-                            calculateType: 'nucleusSettingsUpdated',
-                            color: NucleusColors.green,
-                            emoji: "CONTROL.BLOCKTICK",
-                            timestamp: new Date().getTime()
-                        },
-                        list: {
-                            memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
-                            changedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                            role: entry(role.id, renderRole(role)),
-                        },
-                        hidden: {
-                            guild: interaction.guild.id
-                        }
+                const { log, NucleusColors, entry, renderUser, renderRole } = client.logger;
+                const data = {
+                    meta:{
+                        type: "verifyRoleChanged",
+                        displayName: "Verify Role Changed",
+                        calculateType: "nucleusSettingsUpdated",
+                        color: NucleusColors.green,
+                        emoji: "CONTROL.BLOCKTICK",
+                        timestamp: new Date().getTime()
+                    },
+                    list: {
+                        memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
+                        changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+                        role: entry(role.id, renderRole(role))
+                    },
+                    hidden: {
+                        guild: interaction.guild.id
                     }
-                    log(data);
-                } catch {}
+                };
+                log(data);
             } catch (e) {
-                console.log(e)
+                console.log(e);
                 return interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Verify Role")
-                    .setDescription(`Something went wrong while setting the verify role`)
+                    .setDescription("Something went wrong while setting the verify role")
                     .setStatus("Danger")
                     .setEmoji("GUILD.ROLES.DELETE")
                 ], components: []});
@@ -83,19 +81,19 @@
         } else {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify Role")
-                .setDescription(`No changes were made`)
+                .setDescription("No changes were made")
                 .setStatus("Success")
                 .setEmoji("GUILD.ROLES.CREATE")
             ], components: []});
         }
     }
     let clicks = 0;
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const data = await client.database.guilds.read(interaction.guild.id);
     let role = data.verify.role;
     while (true) {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify Role")
-            .setDescription(role ? `Your verify role is currently set to <@&${role}>` : `You have not set a verify role`)
+            .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([
@@ -114,21 +112,21 @@
         let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
-        } catch(e) { break }
-        i.deferUpdate()
+        } catch(e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "clear") {
             clicks += 1;
             if (clicks === 2) {
                 clicks = 0;
-                await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"])
+                await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]);
                 role = undefined;
             }
         } else if (i.component.customId === "send") {
             const verifyMessages = [
                 {label: "Verify", description: "Click the button below to get verified"},
                 {label: "Get verified", description: "To get access to the rest of the server, click the button below"},
-                {label: "Ready to verify?", description: "Click the button below to verify yourself"},
-            ]
+                {label: "Ready to verify?", description: "Click the button below to verify yourself"}
+            ];
             while (true) {
                 await interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Verify Button")
@@ -139,8 +137,8 @@
                 ], components: [
                     new MessageActionRow().addComponents([
                         new MessageSelectMenu().setOptions(verifyMessages.map((t: {label: string, description: string, value?: string}, index) => {
-                            t.value = index.toString(); return t as {value: string, label: string, description: string}
-                        })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template"),
+                            t.value = index.toString(); return t as {value: string, label: string, description: string};
+                        })).setCustomId("template").setMaxValues(1).setMinValues(1).setPlaceholder("Select a message template")
                     ]),
                     new MessageActionRow().addComponents([
                         new MessageButton()
@@ -162,9 +160,9 @@
                 let i;
                 try {
                     i = await m.awaitMessageComponent({time: 300000});
-                } catch(e) { break }
+                } catch(e) { break; }
                 if (i.component.customId === "template") {
-                    i.deferUpdate()
+                    i.deferUpdate();
                     await interaction.channel.send({embeds: [new EmojiEmbed()
                         .setTitle(verifyMessages[parseInt(i.values[0])].label)
                         .setDescription(verifyMessages[parseInt(i.values[0])].description)
@@ -176,18 +174,18 @@
                         .setStyle("SUCCESS")
                         .setCustomId("verifybutton")
                     ])]});
-                    break
+                    break;
                 } else if (i.component.customId === "blank") {
-                    i.deferUpdate()
+                    i.deferUpdate();
                     await interaction.channel.send({components: [new MessageActionRow().addComponents([new MessageButton()
                         .setLabel("Verify")
                         .setEmoji(getEmojiByName("CONTROL.TICK", "id"))
                         .setStyle("SUCCESS")
                         .setCustomId("verifybutton")
                     ])]});
-                    break
+                    break;
                 } else if (i.component.customId === "custom") {
-                    await i.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Enter embed details`).addComponents(
+                    await i.showModal(new Discord.Modal().setCustomId("modal").setTitle("Enter embed details").addComponents(
                         new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
                             .setCustomId("title")
                             .setLabel("Title")
@@ -202,7 +200,7 @@
                             .setRequired(true)
                             .setStyle("PARAGRAPH")
                         )
-                    ))
+                    ));
                     await interaction.editReply({
                         embeds: [new EmojiEmbed()
                             .setTitle("Verify Button")
@@ -218,11 +216,11 @@
                     });
                     let out;
                     try {
-                        out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify")
-                    } catch (e) { break }
+                        out = await modalInteractionCollector(m, (m) => m.channel.id === interaction.channel.id, (m) => m.customId === "modify");
+                    } catch (e) { break; }
                     if (out.fields) {
-                        let title = out.fields.getTextInputValue("title");
-                        let description = out.fields.getTextInputValue("description");
+                        const title = out.fields.getTextInputValue("title");
+                        const description = out.fields.getTextInputValue("description");
                         await interaction.channel.send({embeds: [new EmojiEmbed()
                             .setTitle(title)
                             .setDescription(description)
@@ -234,23 +232,23 @@
                             .setStyle("SUCCESS")
                             .setCustomId("verifybutton")
                         ])]});
-                        break
-                    } else { continue }
+                        break;
+                    } else { continue; }
                 }
             }
         } else {
-            i.deferUpdate()
+            i.deferUpdate();
             break;
         }
     }
     await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
-}
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 1a107ed..34ac292 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -1,109 +1,107 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import client from '../../utils/client.js';
-import confirmationMessage from '../../utils/confirmationMessage.js';
-import generateKeyValueList from '../../utils/generateKeyValueList.js';
-import { ChannelType } from 'discord-api-types';
-import getEmojiByName from '../../utils/getEmojiByName.js';
+import client from "../../utils/client.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import generateKeyValueList from "../../utils/generateKeyValueList.js";
+import { ChannelType } from "discord-api-types";
+import getEmojiByName from "../../utils/getEmojiByName.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("welcome")
-    .setDescription("Messages and roles sent or given when someone joins the server")
-    .addStringOption(option => option.setName("message").setDescription("The message to send when someone joins the server").setAutocomplete(true))
-    .addRoleOption(option => option.setName("role").setDescription("The role given when someone joins the server"))
-    .addRoleOption(option => option.setName("ping").setDescription("The role pinged when someone joins the server"))
-    .addChannelOption(option => option.setName("channel").setDescription("The channel the welcome message should be sent to").addChannelTypes([
-        ChannelType.GuildText, ChannelType.GuildNews
-    ]))
+        .setName("welcome")
+        .setDescription("Messages and roles sent or given when someone joins the server")
+        .addStringOption(option => option.setName("message").setDescription("The message to send when someone joins the server").setAutocomplete(true))
+        .addRoleOption(option => option.setName("role").setDescription("The role given when someone joins the server"))
+        .addRoleOption(option => option.setName("ping").setDescription("The role pinged when someone joins the server"))
+        .addChannelOption(option => option.setName("channel").setDescription("The channel the welcome message should be sent to").addChannelTypes([
+            ChannelType.GuildText, ChannelType.GuildNews
+        ]));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger
+    const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } = client.logger;
     await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
     let m;
     if (interaction.options.getRole("role") || interaction.options.getChannel("channel") || interaction.options.getString("message")) {
         let role;
         let ping;
-        let message = interaction.options.getString("message");
+        const message = interaction.options.getString("message");
         try {
-            role = interaction.options.getRole("role")
-            ping = interaction.options.getRole("ping")
+            role = interaction.options.getRole("role");
+            ping = interaction.options.getRole("ping");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("GUILD.ROLES.DELETE")
                 .setTitle("Welcome Events")
                 .setDescription("The role you provided is not a valid role")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
         let channel;
         try {
-            channel = interaction.options.getChannel("channel")
+            channel = interaction.options.getChannel("channel");
         } catch {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setEmoji("GUILD.ROLES.DELETE")
                 .setTitle("Welcome Events")
                 .setDescription("The channel you provided is not a valid channel")
                 .setStatus("Danger")
-            ]})
+            ]});
         }
-        role = role as Discord.Role
-        ping = ping as Discord.Role
-        channel = channel as Discord.TextChannel
-        let options = {}
-        if (role) options["role"] = renderRole(role)
-        if (ping) options["ping"] = renderRole(ping)
-        if (channel) options["channel"] = renderChannel(channel)
-        if (message) options["message"] = "\n> " + message
-        let confirmation = await new confirmationMessage(interaction)
+        role = role as Discord.Role;
+        ping = ping as Discord.Role;
+        channel = channel as Discord.TextChannel;
+        const options = {};
+        if (role) options["role"] = renderRole(role);
+        if (ping) options["ping"] = renderRole(ping);
+        if (channel) options["channel"] = renderChannel(channel);
+        if (message) options["message"] = "\n> " + message;
+        const confirmation = await new confirmationMessage(interaction)
             .setEmoji("GUILD.ROLES.EDIT")
             .setTitle("Welcome Events")
             .setDescription(generateKeyValueList(options))
             .setColor("Warning")
             .setInverted(true)
-        .send(true)
-        if (confirmation.cancelled) return
+            .send(true);
+        if (confirmation.cancelled) return;
         if (confirmation.success) {
             try {
-                let toChange = {}
-                if (role) toChange["welcome.role"] = role.id
-                if (ping) toChange["welcome.ping"] = ping.id
-                if (channel) toChange["welcome.channel"] = channel.id
-                if (message) toChange["welcome.message"] = message
+                const toChange = {};
+                if (role) toChange["welcome.role"] = role.id;
+                if (ping) toChange["welcome.ping"] = ping.id;
+                if (channel) toChange["welcome.channel"] = channel.id;
+                if (message) toChange["welcome.message"] = message;
                 await client.database.guilds.write(interaction.guild.id, toChange);
-                let list = {
+                const list = {
                     memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
                     changedBy: entry(interaction.user.id, renderUser(interaction.user))
-                }
-                if (role) list["role"] = entry(role.id, renderRole(role))
-                if (ping) list["ping"] = entry(ping.id, renderRole(ping))
-                if (channel) list["channel"] = entry(channel.id, renderChannel(channel.id))
-                if (message) list["message"] = entry(message, `\`${message}\``)
-                try {
-                    let data = {
-                        meta:{
-                            type: 'welcomeSettingsUpdated',
-                            displayName: 'Welcome Settings Changed',
-                            calculateType: 'nucleusSettingsUpdated',
-                            color: NucleusColors.green,
-                            emoji: "CONTROL.BLOCKTICK",
-                            timestamp: new Date().getTime()
-                        },
-                        list: list,
-                        hidden: {
-                            guild: interaction.guild.id
-                        }
+                };
+                if (role) list["role"] = entry(role.id, renderRole(role));
+                if (ping) list["ping"] = entry(ping.id, renderRole(ping));
+                if (channel) list["channel"] = entry(channel.id, renderChannel(channel.id));
+                if (message) list["message"] = entry(message, `\`${message}\``);
+                const data = {
+                    meta:{
+                        type: "welcomeSettingsUpdated",
+                        displayName: "Welcome Settings Changed",
+                        calculateType: "nucleusSettingsUpdated",
+                        color: NucleusColors.green,
+                        emoji: "CONTROL.BLOCKTICK",
+                        timestamp: new Date().getTime()
+                    },
+                    list: list,
+                    hidden: {
+                        guild: interaction.guild.id
                     }
-                    log(data);
-                } catch {}
+                };
+                log(data);
             } catch (e) {
-                console.log(e)
+                console.log(e);
                 return interaction.editReply({embeds: [new EmojiEmbed()
                     .setTitle("Welcome Events")
-                    .setDescription(`Something went wrong while updating welcome settings`)
+                    .setDescription("Something went wrong while updating welcome settings")
                     .setStatus("Danger")
                     .setEmoji("GUILD.ROLES.DELETE")
                 ], components: []});
@@ -111,15 +109,15 @@
         } else {
             return interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Welcome Events")
-                .setDescription(`No changes were made`)
+                .setDescription("No changes were made")
                 .setStatus("Success")
                 .setEmoji("GUILD.ROLES.CREATE")
             ], components: []});
         }
     }
-    let lastClicked = null
+    let lastClicked = null;
     while (true) {
-        let config = await client.database.guilds.read(interaction.guild.id)
+        const config = await client.database.guilds.read(interaction.guild.id);
         m = await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Welcome Events")
             .setDescription(
@@ -162,47 +160,47 @@
                     .setDisabled(config.welcome.channel == "dm")
                     .setStyle("SECONDARY")
             ])
-        ]})
+        ]});
         let i;
         try {
             i = await m.awaitMessageComponent({ time: 300000 });
         } catch (e) {
-            break
+            break;
         }
-        i.deferUpdate()
+        i.deferUpdate();
         if (i.customId == "clear-message") {
             if (lastClicked == "clear-message") {
                 await client.database.guilds.write(interaction.guild.id, {"welcome.message": null});
-                lastClicked = null
-            } else { lastClicked = "clear-message" }
+                lastClicked = null;
+            } else { lastClicked = "clear-message"; }
         } else if (i.customId == "clear-role") {
             if (lastClicked == "clear-role") {
                 await client.database.guilds.write(interaction.guild.id, {"welcome.role": null});
-                lastClicked = null
-            } else { lastClicked = "clear-role" }
+                lastClicked = null;
+            } else { lastClicked = "clear-role"; }
         } else if (i.customId == "clear-ping") {
             if (lastClicked == "clear-ping") {
                 await client.database.guilds.write(interaction.guild.id, {"welcome.ping": null});
-                lastClicked = null
-            } else { lastClicked = "clear-ping" }
+                lastClicked = null;
+            } else { lastClicked = "clear-ping"; }
         } else if (i.customId == "clear-channel") {
             if (lastClicked == "clear-channel") {
                 await client.database.guilds.write(interaction.guild.id, {"welcome.channel": null});
-                lastClicked = null
-            } else { lastClicked = "clear-channel" }
+                lastClicked = null;
+            } else { lastClicked = "clear-channel"; }
         } else if (i.customId == "set-channel-dm") {
             await client.database.guilds.write(interaction.guild.id, {"welcome.channel": "dm"});
-            lastClicked = null
+            lastClicked = null;
         }
     }
     await interaction.editReply({embeds: [m.embeds[0].setFooter({text: "Message closed"})], components: []});
-}
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/tag.ts b/src/commands/tag.ts
index 70d5a75..4cae8e3 100644
--- a/src/commands/tag.ts
+++ b/src/commands/tag.ts
@@ -1,35 +1,35 @@
 import { AutocompleteInteraction, CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import { SlashCommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
-import client from "../utils/client.js"
+import client from "../utils/client.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 
 const command = new SlashCommandBuilder()
     .setName("tag")
     .setDescription("Get and manage the servers tags")
-    .addStringOption(o => o.setName("tag").setDescription("The tag to get").setAutocomplete(true).setRequired(true))
+    .addStringOption(o => o.setName("tag").setDescription("The tag to get").setAutocomplete(true).setRequired(true));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const config = await client.database.guilds.read(interaction.guild.id)
-    const tags = config.getKey("tags")
-    const tag = tags[interaction.options.getString("tag")]
+    const config = await client.database.guilds.read(interaction.guild.id);
+    const tags = config.getKey("tags");
+    const tag = tags[interaction.options.getString("tag")];
     if (!tag) {
         return await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Tag")
             .setDescription(`Tag \`${interaction.options.getString("tag")}\` does not exist`)
             .setEmoji("PUNISH.NICKNAME.RED")
             .setStatus("Danger")
-        ], ephemeral: true})
+        ], ephemeral: true});
     }
-    let url = ""
-    let components = []
+    let url = "";
+    let components = [];
     if (tag.match(/^(http|https):\/\/[^ "]+$/)) {
-        url = tag
+        url = tag;
         components = [new MessageActionRow().addComponents([new MessageButton()
             .setLabel("Open")
             .setURL(url)
             .setStyle("LINK")
-        ])]
+        ])];
     }
     return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle(interaction.options.getString("tag"))
@@ -37,20 +37,20 @@
         .setEmoji("PUNISH.NICKNAME.GREEN")
         .setStatus("Success")
         .setImage(url)
-    ], components: components, ephemeral: true})
+    ], components: components, ephemeral: true});
 
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
     if (!interaction.guild) return [];
-    const config = await client.database.guilds.read(interaction.guild.id)
+    const config = await client.database.guilds.read(interaction.guild.id);
     const tags = Object.keys(config.getKey("tags"));
-    return tags
-}
+    return tags;
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/tags/create.ts b/src/commands/tags/create.ts
index 4615def..d2f15e1 100644
--- a/src/commands/tags/create.ts
+++ b/src/commands/tags/create.ts
@@ -8,14 +8,14 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("create")
-    .setDescription("Creates a tag")
-    .addStringOption(o => o.setName("name").setRequired(true).setDescription("The name of the tag"))
-    .addStringOption(o => o.setName("value").setRequired(true).setDescription("The value of the tag, shown after running /tag name"))
+        .setName("create")
+        .setDescription("Creates a tag")
+        .addStringOption(o => o.setName("name").setRequired(true).setDescription("The name of the tag"))
+        .addStringOption(o => o.setName("value").setRequired(true).setDescription("The value of the tag, shown after running /tag name"));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let name = interaction.options.getString("name");
-    let value = interaction.options.getString("value");
+    const name = interaction.options.getString("name");
+    const value = interaction.options.getString("value");
     if (name.length > 100) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Tag Create")
         .setDescription("Tag names cannot be longer than 100 characters")
@@ -28,7 +28,7 @@
         .setStatus("Danger")
         .setEmoji("PUNISH.NICKNAME.RED")
     ], ephemeral: true});
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const data = await client.database.guilds.read(interaction.guild.id);
     if (data.tags.length >= 100) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Tag Create")
         .setDescription("You cannot have more than 100 tags")
@@ -41,18 +41,18 @@
         .setStatus("Danger")
         .setEmoji("PUNISH.NICKNAME.RED")
     ], ephemeral: true});
-    let confirmation = await new confirmationMessage(interaction)
-    .setEmoji("PUNISH.NICKNAME.YELLOW")
+    const confirmation = await new confirmationMessage(interaction)
+        .setEmoji("PUNISH.NICKNAME.YELLOW")
         .setTitle("Tag create")
         .setDescription(keyValueList({
             "name": `${name}`,
             "value": `\n> ${value}`
         })
-        + `\nAre you sure you want to create this tag?`)
+        + "\nAre you sure you want to create this tag?")
         .setColor("Warning")
         .setInverted(true)
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Tag Create")
         .setDescription("No changes were made")
@@ -75,13 +75,13 @@
         .setStatus("Success")
         .setEmoji("PUNISH.NICKNAME.GREEN")
     ], components: []});
-}
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/tags/delete.ts b/src/commands/tags/delete.ts
index 68a02d4..5a6d3d4 100644
--- a/src/commands/tags/delete.ts
+++ b/src/commands/tags/delete.ts
@@ -8,31 +8,31 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("delete")
-    .setDescription("Deletes a tag")
-    .addStringOption(o => o.setName("name").setRequired(true).setDescription("The name of the tag"))
+        .setName("delete")
+        .setDescription("Deletes a tag")
+        .addStringOption(o => o.setName("name").setRequired(true).setDescription("The name of the tag"));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let name = interaction.options.getString("name");
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const name = interaction.options.getString("name");
+    const data = await client.database.guilds.read(interaction.guild.id);
     if (!data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Tags")
         .setDescription("That tag does not exist")
         .setStatus("Danger")
         .setEmoji("PUNISH.NICKNAME.RED")
     ], ephemeral: true});
-    let confirmation = await new confirmationMessage(interaction)
+    const confirmation = await new confirmationMessage(interaction)
         .setEmoji("PUNISH.NICKNAME.YELLOW")
         .setTitle("Tag Delete")
         .setDescription(keyValueList({
             "name": `${name}`,
             "value": `\n> ${data.tags[name]}`
         })
-        + `\nAre you sure you want to delete this tag?`)
+        + "\nAre you sure you want to delete this tag?")
         .setColor("Warning")
         .setInverted(true)
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Tag Delete")
         .setDescription("No changes were made")
@@ -42,7 +42,7 @@
     try {
         await client.database.guilds.write(interaction.guild.id, null, ["tags." + name]);
     } catch (e) {
-        console.log(e)
+        console.log(e);
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Tag Delete")
             .setDescription("Something went wrong and the tag was not deleted")
@@ -56,13 +56,13 @@
         .setStatus("Success")
         .setEmoji("PUNISH.NICKNAME.GREEN")
     ], components: []});
-}
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 2f585cd..f3698fc 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -8,16 +8,16 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("edit")
-    .setDescription("Edits or renames a tag")
-    .addStringOption(o => o.setName("name").setRequired(true).setDescription("The tag to edit"))
-    .addStringOption(o => o.setName("value").setRequired(false).setDescription("The new value of the tag / Rename"))
-    .addStringOption(o => o.setName("newname").setRequired(false).setDescription("The new name of the tag / Edit"))
+        .setName("edit")
+        .setDescription("Edits or renames a tag")
+        .addStringOption(o => o.setName("name").setRequired(true).setDescription("The tag to edit"))
+        .addStringOption(o => o.setName("value").setRequired(false).setDescription("The new value of the tag / Rename"))
+        .addStringOption(o => o.setName("newname").setRequired(false).setDescription("The new name of the tag / Edit"));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let name = interaction.options.getString("name");
-    let value = interaction.options.getString("value") || "";
-    let newname = interaction.options.getString("newname") || "";
+    const name = interaction.options.getString("name");
+    const value = interaction.options.getString("value") || "";
+    const newname = interaction.options.getString("newname") || "";
     if (!newname && !value) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Tag Edit")
         .setDescription("You must specify a value or a new name")
@@ -36,7 +36,7 @@
         .setStatus("Danger")
         .setEmoji("PUNISH.NICKNAME.RED")
     ], ephemeral: true});
-    let data = await client.database.guilds.read(interaction.guild.id);
+    const data = await client.database.guilds.read(interaction.guild.id);
     if (!data.tags[name]) return await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("Tag Edit")
         .setDescription("That tag does not exist")
@@ -49,18 +49,18 @@
         .setStatus("Danger")
         .setEmoji("PUNISH.NICKNAME.RED")
     ], ephemeral: true});
-    let confirmation = await new confirmationMessage(interaction)
-    .setEmoji("PUNISH.NICKNAME.YELLOW")
+    const confirmation = await new confirmationMessage(interaction)
+        .setEmoji("PUNISH.NICKNAME.YELLOW")
         .setTitle("Tag Edit")
         .setDescription(keyValueList({
             "name": `${name}` + (newname ? ` -> ${newname}` : ""),
             "value": `\n> ${value ? value : data.tags[name]}`
         })
-        + `\nAre you sure you want to edit this tag?`)
+        + "\nAre you sure you want to edit this tag?")
         .setColor("Warning")
         .setInverted(true)
-    .send()
-    if (confirmation.cancelled) return
+        .send();
+    if (confirmation.cancelled) return;
     if (!confirmation) return await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Tag Edit")
         .setDescription("No changes were made")
@@ -68,8 +68,8 @@
         .setEmoji("PUNISH.NICKNAME.GREEN")
     ]});
     try {
-        let toSet = {};
-        let toUnset = []
+        const toSet = {};
+        const toUnset = [];
         if (value) toSet[`tags.${name}`] = value;
         if (newname) {
             toUnset.push(`tags.${name}`);
@@ -90,13 +90,13 @@
         .setStatus("Success")
         .setEmoji("PUNISH.NICKNAME.GREEN")
     ], components: []});
-}
+};
 
 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"
+    const member = (interaction.member as Discord.GuildMember);
+    if (!member.permissions.has("MANAGE_MESSAGES")) throw "You must have the *Manage Messages* permission to use this command";
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts
index c335267..7f3637f 100644
--- a/src/commands/tags/list.ts
+++ b/src/commands/tags/list.ts
@@ -1,10 +1,10 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import client from "../../utils/client.js";
-import { SelectMenuOption } from '@discordjs/builders';
+import { SelectMenuOption } from "@discordjs/builders";
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import createPageIndicator from "../../utils/createPageIndicator.js";
 
@@ -12,8 +12,8 @@
 class Embed {
     embed: Discord.MessageEmbed;
     title: string;
-    description: string = "";
-    pageId: number = 0;
+    description = "";
+    pageId = 0;
     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; }
@@ -23,61 +23,61 @@
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
         .setName("list")
-        .setDescription("Lists all tags in the server")
+        .setDescription("Lists all tags in the server");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    let data = await client.database.guilds.read(interaction.guild.id);
-    let tags = data.getKey("tags");
-    let strings = []
-    if (data === {}) strings = ["*No tags exist*"]
+    const data = await client.database.guilds.read(interaction.guild.id);
+    const tags = data.getKey("tags");
+    let strings = [];
+    if (data === {}) strings = ["*No tags exist*"];
     else {
-        let string = ""
-        for (let tag in tags) {
-            let proposed = `**${tag}:** ${tags[tag]}\n`
+        let string = "";
+        for (const tag in tags) {
+            const proposed = `**${tag}:** ${tags[tag]}\n`;
             if (string.length + proposed.length > 2000) {
-                strings.push(string.slice(0, -1))
-                string = ""
+                strings.push(string.slice(0, -1));
+                string = "";
             }
-            string += proposed
+            string += proposed;
         }
-        strings.push(string.slice(0, -1))
+        strings.push(string.slice(0, -1));
     }
 
-    let pages = []
-    for (let string of strings) {
+    const pages = [];
+    for (const string of strings) {
         pages.push(new Embed()
             .setEmbed(new EmojiEmbed()
                 .setTitle("Tags")
                 .setDescription(string)
                 .setEmoji("PUNISH.NICKNAME.GREEN")
                 .setStatus("Success")
-            ).setTitle(`Page ${pages.length + 1}`).setPageId(pages.length))
+            ).setTitle(`Page ${pages.length + 1}`).setPageId(pages.length));
     }
     let m;
     m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
     let page = 0;
     let selectPaneOpen = false;
     while (true) {
-        let selectPane = []
+        let selectPane = [];
 
         if (selectPaneOpen) {
-            let options = [];
+            const options = [];
             pages.forEach(embed => {
                 options.push(new SelectMenuOption({
                     label: embed.title,
                     value: embed.pageId.toString(),
-                    description: embed.description || "",
-                }))
-            })
+                    description: embed.description || ""
+                }));
+            });
             selectPane = [new MessageActionRow().addComponents([
                 new Discord.MessageSelectMenu()
                     .addOptions(options)
                     .setCustomId("page")
                     .setMaxValues(1)
                     .setPlaceholder("Choose a page...")
-            ])]
+            ])];
         }
-        let em = new Discord.MessageEmbed(pages[page].embed)
+        const em = new Discord.MessageEmbed(pages[page].embed);
         em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
         await interaction.editReply({
             embeds: [em],
@@ -88,11 +88,11 @@
                 new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER")
             ])])
         });
-        let i
+        let i;
         try {
             i = await m.awaitMessageComponent({time: 300000 });
-        } catch (e) { break }
-        i.deferUpdate()
+        } catch (e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
@@ -105,7 +105,7 @@
             page = parseInt(i.values[0]);
             selectPaneOpen = false;
         } else {
-            let em = new Discord.MessageEmbed(pages[page].embed)
+            const em = new Discord.MessageEmbed(pages[page].embed);
             em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message closed");
             await interaction.editReply({
                 embeds: [em], components: [new MessageActionRow().addComponents([
@@ -114,11 +114,11 @@
                     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)
                 ])]
-            })
+            });
             return;
         }
     }
-    let em = new Discord.MessageEmbed(pages[page].embed)
+    const em = new Discord.MessageEmbed(pages[page].embed);
     em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page) + " | Message timed out");
     await interaction.editReply({
         embeds: [em],
@@ -129,11 +129,11 @@
             new MessageButton().setCustomId("close").setEmoji(getEmojiByName("CONTROL.CROSS", "id")).setStyle("DANGER").setDisabled(true)
         ])]
     });
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index 5a3371e..b3e5351 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -5,16 +5,16 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("close")
-    .setDescription("Closes a ticket")
+        .setName("close")
+        .setDescription("Closes a ticket");
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
     await close(interaction);
-}
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index 3d796aa..25de336 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -5,17 +5,17 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("create")
-    .setDescription("Creates a new modmail ticket")
-    .addStringOption(option => option.setName("message").setDescription("The content of the ticket").setRequired(false))
+        .setName("create")
+        .setDescription("Creates a new modmail ticket")
+        .addStringOption(option => option.setName("message").setDescription("The content of the ticket").setRequired(false));
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    await create(interaction)
-}
+    await create(interaction);
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 82eda6a..59ba2e6 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
 import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
@@ -6,20 +6,20 @@
 import getEmojiByName from "../../utils/getEmojiByName.js";
 import generateKeyValueList from "../../utils/generateKeyValueList.js";
 import createPageIndicator from "../../utils/createPageIndicator.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("about")
-    .setDescription("Shows info about a user")
-    .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"))
+        .setName("about")
+        .setDescription("Shows info about a user")
+        .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself"));
 
 
 class Embed {
     embed: Discord.MessageEmbed;
     title: string;
-    description: string = "";
-    pageId: number = 0;
+    description = "";
+    pageId = 0;
     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; }
@@ -28,23 +28,23 @@
 
 
 const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser, renderDelta } = client.logger
-    let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
-    let flags: string[] = [];
+    const { renderUser, renderDelta } = client.logger;
+    const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+    const flags: string[] = [];
     if ([
         "438733159748599813", // Pinea
         "317731855317336067", // Mini
         "261900651230003201", // Coded
-        "511655498676699136", // Zan
-    ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER") }
-    if ((await client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter(m => m.roles.cache.has("760896837866749972"))?.map(m => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER") }
+        "511655498676699136" // Zan
+    ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER"); }
+    if ((await client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter(m => m.roles.cache.has("760896837866749972"))?.map(m => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER"); }
     member.user.flags.toArray().map(flag => {
-        flags.push(flag.toString())
-    })
-    if (member.user.bot === true) { flags.push("BOT") }
+        flags.push(flag.toString());
+    });
+    if (member.user.bot === true) { flags.push("BOT"); }
     // Check if they are boosting the server
-    if (member.premiumSince) { flags.push("BOOSTER") }
-    let nameReplacements = {
+    if (member.premiumSince) { flags.push("BOOSTER"); }
+    const nameReplacements = {
         "NUCLEUSDEVELOPER": "**Nucleus Developer**",
         "CLICKSDEVELOPER": "Clicks Developer",
         "HOUSE_BRAVERY": "Hypesquad Bravery",
@@ -59,31 +59,31 @@
         "EARLY_VERIFIED_BOT_DEVELOPER": "Verified Bot Developer",
         "BOT": "Bot",
         "BOOSTER": "Server Booster"
-    }
-    let members = await interaction.guild.members.fetch()
-    let membersArray = [...members.values()]
-    membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp)
-    let joinPos = membersArray.findIndex(m => m.id === member.user.id)
+    };
+    const members = await interaction.guild.members.fetch();
+    const membersArray = [...members.values()];
+    membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp);
+    const joinPos = membersArray.findIndex(m => m.id === member.user.id);
 
-    let roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort()
+    const roles = member.roles.cache.filter(r => r.id !== interaction.guild.id).sort();
     let s = "";
     let count = 0;
-    let ended = false
+    let ended = false;
     roles.map(item => {
         if (ended) return;
-        let string = `<@&${item.id}>, `
+        const string = `<@&${item.id}>, `;
         if(s.length + string.length > 1000) {
-            ended = true
-            s += `and ${roles.size - count} more`
-            return
-        };
-        count ++
+            ended = true;
+            s += `and ${roles.size - count} more`;
+            return;
+        }
+        count ++;
         s += string;
-    })
+    });
     if(s.length > 0 && !ended) s = s.slice(0, -2);
 
-    let perms = ""
-    let permsArray = {
+    let perms = "";
+    const permsArray = {
         "ADMINISTRATOR": "Administrator",
         "MANAGE_GUILD": "Manage Server",
         "MANAGE_ROLES": "Manage Roles",
@@ -96,15 +96,15 @@
         "MANAGE_MESSAGES": "Manage Messages",
         "VIEW_AUDIT_LOG": "View Audit Log",
         "MENTION_EVERYONE": "Mention Everyone"
-    }
+    };
     Object.keys(permsArray).map(perm => {
-        let hasPerm = member.permissions.has(perm as Discord.PermissionString)
-        perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`
-    })
+        const hasPerm = member.permissions.has(perm as Discord.PermissionString);
+        perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n`;
+    });
 
     let selectPaneOpen = false;
 
-    let embeds = [
+    const embeds = [
         new Embed()
             .setEmbed(new EmojiEmbed()
                 .setTitle("User Info: General")
@@ -138,7 +138,7 @@
                     generateKeyValueList({
                         "member": renderUser(member.user),
                         "id": `\`${member.id}\``,
-                        "roles": `${member.roles.cache.size - 1}`,
+                        "roles": `${member.roles.cache.size - 1}`
                     }) + "\n" +
                     (s.length > 0 ? s : "*None*") + "\n"
                 )
@@ -152,37 +152,37 @@
                 .setDescription(
                     generateKeyValueList({
                         "member": renderUser(member.user),
-                        "id": `\`${member.id}\``,
+                        "id": `\`${member.id}\``
                     }) + "\n" + perms
                 )
                 .setThumbnail(await member.user.displayAvatarURL({dynamic: true}))
-            ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2),
-    ]
-    let m
+            ).setTitle("Key Permissions").setDescription("Key permissions the user has").setPageId(2)
+    ];
+    let m;
     m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
-    let page = 0
-    let breakReason = ""
+    let page = 0;
+    let breakReason = "";
     while (true) {
-        let em = new Discord.MessageEmbed(embeds[page].embed)
+        const em = new Discord.MessageEmbed(embeds[page].embed);
         em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page));
-        let selectPane = []
+        let selectPane = [];
 
         if (selectPaneOpen) {
-            let options = [];
+            const options = [];
             embeds.forEach(embed => {
                 options.push(new SelectMenuOption({
                     label: embed.title,
                     value: embed.pageId.toString(),
-                    description: embed.description || "",
-                }))
-            })
+                    description: embed.description || ""
+                }));
+            });
             selectPane = [new MessageActionRow().addComponents([
                 new Discord.MessageSelectMenu()
                     .addOptions(options)
                     .setCustomId("page")
                     .setMaxValues(1)
                     .setPlaceholder("Choose a page...")
-            ])]
+            ])];
         }
         await interaction.editReply({
             embeds: [em],
@@ -207,12 +207,12 @@
                     .setCustomId("close")
                     .setStyle("DANGER")
             ])])
-        })
-        let i
+        });
+        let i;
         try {
             i = await m.awaitMessageComponent({time: 300000});
-        } catch { breakReason = "Message timed out"; break }
-        i.deferUpdate()
+        } catch { breakReason = "Message timed out"; break; }
+        i.deferUpdate();
         if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
@@ -232,7 +232,7 @@
             break;
         }
     }
-    let em = new Discord.MessageEmbed(embeds[page].embed)
+    const em = new Discord.MessageEmbed(embeds[page].embed);
     em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page) + " | " + breakReason);
     await interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
         new MessageButton()
@@ -255,12 +255,12 @@
             .setCustomId("close")
             .setStyle("DANGER")
             .setDisabled(true)
-    ])]})
-}
+    ])]});
+};
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index e72506f..8f327a5 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -2,19 +2,18 @@
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
 import generateKeyValueList from "../../utils/generateKeyValueList.js";
-import client from "../../utils/client.js"
+import client from "../../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("avatar")
-    .setDescription("Shows the avatar of a user")
-    .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"))
+        .setName("avatar")
+        .setDescription("Shows the avatar of a user")
+        .addUserOption(option => option.setName("user").setDescription("The user to get the avatar of | Default: Yourself"));
 
-const callback = async (interaction: CommandInteraction): Promise<any> => {
-    const { renderUser } = client.logger
-    let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
+const callback = async (interaction: CommandInteraction): Promise<void> => {
+    const { renderUser } = client.logger;
+    const member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember;
     await interaction.reply({embeds: [new EmojiEmbed()
         .setTitle("User Info")
         .setStatus("Success")
@@ -22,16 +21,16 @@
         .setDescription(
             generateKeyValueList({
                 "member": renderUser(member.user),
-                "url": member.user.displayAvatarURL({dynamic: true}),
+                "url": member.user.displayAvatarURL({dynamic: true})
             })
         )
         .setImage(await member.user.displayAvatarURL({dynamic: true}))
     ], ephemeral: true, fetchReply: true});
-}
+};
 
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index c2e0986..48733fc 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,6 +1,8 @@
-import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
 import Discord, { CommandInteraction, GuildMember, Message, MessageActionRow, MessageButton } from "discord.js";
 import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
@@ -9,91 +11,92 @@
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
-    .setName("track")
-    .setDescription("Moves a user along a role track")
-    .addUserOption(option => option.setName("user").setDescription("The user to manage").setRequired(true))
+        .setName("track")
+        .setDescription("Moves a user along a role track")
+        .addUserOption(option => option.setName("user").setDescription("The user to manage").setRequired(true));
 
-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
-    return "TRACKS.VERTICAL.MIDDLE." + disabled + active
-}
+const generateFromTrack = (position: number, active: string | boolean, size: number, disabled: string | boolean) => {
+    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;
+    return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
+};
 
-const callback = async (interaction: CommandInteraction): Promise<any> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
     const { renderUser } = client.logger;
     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: LoadingEmbed, ephemeral: true})
-    let track = 0
+    if (!guild) return;
+    const config = await client.database.guilds.read(guild.id);
+    await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+    let track = 0;
     let generated;
-    const roles = await guild.roles.fetch()
-    let memberRoles = await member.roles
-    let managed
+    const roles = await guild.roles.fetch();
+    const memberRoles = await member.roles;
+    let managed: boolean;
     while (true) {
-        let data = config.tracks[track]
-        if (data.manageableBy !== undefined) managed = data.manageableBy.some(element => {return memberRoles.cache.has(element)})
-        else managed = false
-        let dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
-            let hasRoleInTrack = option.track.some(element => {return memberRoles.cache.has(element)})
+        const data = config.tracks[track];
+        if (data.manageableBy !== undefined) managed = data.manageableBy.some((element: string) => {return memberRoles.cache.has(element);});
+        else managed = false;
+        const dropdown = new Discord.MessageSelectMenu().addOptions(config.tracks.map((option, index) => {
+            const hasRoleInTrack = option.track.some((element: string) => {return memberRoles.cache.has(element);});
             return new SelectMenuOption({
                 default: index === track,
                 label: option.name,
                 value: index.toString(),
                 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)
-        let allowed = []
-        generated = "**Track:** " + data.name + "\n" + "**Member:** " + renderUser(member.user) + "\n"
-        generated += (data.nullable ? "Members do not need a role in this track" : "A role in this track is required") + "\n"
-        generated += (data.retainPrevious ? "When promoted, the user keeps previous roles" : "Members will lose their current role when promoted") + "\n"
+            });
+        })).setCustomId("select").setMaxValues(1);
+        const allowed = [];
+        generated = "**Track:** " + data.name + "\n" + "**Member:** " + renderUser(member.user) + "\n";
+        generated += (data.nullable ? "Members do not need a role in this track" : "A role in this track is required") + "\n";
+        generated += (data.retainPrevious ? "When promoted, the user keeps previous roles" : "Members will lose their current role when promoted") + "\n";
         generated += "\n" + data.track.map((role, index) => {
-            let allow = (roles.get(role).position >= (interaction.member as GuildMember).roles.highest.position) && !managed
-            allowed.push(!allow)
+            const allow = (roles.get(role).position >= (interaction.member as GuildMember).roles.highest.position) && !managed;
+            allowed.push(!allow);
             return getEmojiByName(generateFromTrack(
                 index,
                 memberRoles.cache.has(role),
                 data.track.length,
                 allow
             )) + " " +
-            roles.get(role).name + " [<@&" + roles.get(role).id + ">]"
-        }).join("\n")
-        let selected = [];
+            roles.get(role).name + " [<@&" + roles.get(role).id + ">]";
+        }).join("\n");
+        const selected = [];
         for (let i = 0; i < data.track.length; i++) {
-            if (memberRoles.cache.has(data.track[i])) selected.push(data.track[i])
+            if (memberRoles.cache.has(data.track[i])) selected.push(data.track[i]);
         }
-        let conflict = data.retainPrevious ? false : selected.length > 1;
-        let conflictDropdown
-        let currentRoleIndex
+        const conflict = data.retainPrevious ? false : selected.length > 1;
+        let conflictDropdown;
+        let currentRoleIndex;
         if (conflict) {
-            generated += `\n\n${getEmojiByName(`PUNISH.WARN.${managed ? "YELLOW" : "RED"}`)} This user has ${selected.length} roles from this track. `
-            conflictDropdown = []
+            generated += `\n\n${getEmojiByName(`PUNISH.WARN.${managed ? "YELLOW" : "RED"}`)} This user has ${selected.length} roles from this track. `;
+            conflictDropdown = [];
             if (
                 (roles.get(selected[0]).position < memberRoles.highest.position) || managed
             ) {
-                generated +=  `In order to promote or demote this user, you must select which role the member should keep.`
+                generated +=  "In order to promote or demote this user, you must select which role the member should keep.";
                 selected.forEach(role => {
                     conflictDropdown.push(new SelectMenuOption({
                         label: roles.get(role).name,
-                        value: roles.get(role).id,
-                    }))
-                })
+                        value: roles.get(role).id
+                    }));
+                });
                 conflictDropdown = [new Discord.MessageSelectMenu()
                     .addOptions(conflictDropdown)
                     .setCustomId("conflict")
                     .setMaxValues(1)
-                    .setPlaceholder("Select a role to keep")]
+                    .setPlaceholder("Select a role to keep")];
             } else {
-                generated += "You don't have permission to manage one or more of the users roles, and therefore can't select one to keep."
+                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()
+        const m = await interaction.editReply({embeds: [new EmojiEmbed()
             .setEmoji("TRACKS.ICON")
             .setTitle("Tracks")
             .setDescription(`${generated}`)
@@ -101,82 +104,82 @@
         ], components: [
             new MessageActionRow().addComponents(dropdown)
         ]
-        .concat(conflict && conflictDropdown.length ? [new MessageActionRow().addComponents(conflictDropdown)] : [])
-        .concat([
-            new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setEmoji(getEmojiByName("CONTROL.UP", "id"))
-                    .setLabel("Move up")
-                    .setCustomId("promote")
-                    .setStyle("SUCCESS")
-                    .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
-                new MessageButton()
-                    .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
-                    .setLabel("Move down")
-                    .setCustomId("demote")
-                    .setStyle("DANGER")
-                    .setDisabled(conflict || (
-                        data.nullable ? currentRoleIndex <= -1 :
-                        currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
-                    ) || !allowed[currentRoleIndex]),
-            ])
-        ])})
+            .concat(conflict && conflictDropdown.length ? [new MessageActionRow().addComponents(conflictDropdown)] : [])
+            .concat([
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setEmoji(getEmojiByName("CONTROL.UP", "id"))
+                        .setLabel("Move up")
+                        .setCustomId("promote")
+                        .setStyle("SUCCESS")
+                        .setDisabled(conflict || currentRoleIndex === 0 || (currentRoleIndex === -1 ? false : !allowed[currentRoleIndex - 1])),
+                    new MessageButton()
+                        .setEmoji(getEmojiByName("CONTROL.DOWN", "id"))
+                        .setLabel("Move down")
+                        .setCustomId("demote")
+                        .setStyle("DANGER")
+                        .setDisabled(conflict || (
+                            data.nullable ? currentRoleIndex <= -1 :
+                                currentRoleIndex === data.track.length - 1 || currentRoleIndex <= -1
+                        ) || !allowed[currentRoleIndex])
+                ])
+            ])});
         let component;
         try {
             component = await (m as Message).awaitMessageComponent({time: 300000});
         } catch (e) {
-            return
+            return;
         }
-        component.deferUpdate()
+        component.deferUpdate();
         if (component.customId === "conflict") {
-            let rolesToRemove = selected.filter(role => role !== component.values[0])
-            await member.roles.remove(rolesToRemove)
+            const rolesToRemove = selected.filter(role => role !== component.values[0]);
+            await member.roles.remove(rolesToRemove);
         } else if (component.customId === "promote") {
             if (
                 currentRoleIndex === -1 ? allowed[data.track.length - 1] :
-                allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
+                    allowed[currentRoleIndex - 1] && allowed[currentRoleIndex]
             ) {
                 if (currentRoleIndex === -1) {
-                    await member.roles.add(data.track[data.track.length - 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])
+                    if (!data.retainPrevious) await member.roles.remove(data.track[currentRoleIndex]);
+                    await member.roles.add(data.track[currentRoleIndex - 1]);
                 }
             }
         } else if (component.customId === "demote") {
             if(allowed[currentRoleIndex]) {
                 if (currentRoleIndex === data.track.length - 1) {
-                    if (data.nullable) await member.roles.remove(data.track[currentRoleIndex])
+                    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])
+                    await member.roles.remove(data.track[currentRoleIndex]);
+                    await member.roles.add(data.track[currentRoleIndex + 1]);
                 }
             }
         } else if (component.customId === "select") {
-            track = component.values[0]
+            track = component.values[0];
         }
     }
-}
+};
 
-const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    let tracks = (await client.database.guilds.read(interaction.guild.id)).tracks
-    if (tracks.length === 0) throw "This server does not have any tracks"
-    let member = (interaction.member as GuildMember)
+const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+    const tracks = (await client.database.guilds.read(interaction.guild.id)).tracks;
+    if (tracks.length === 0) throw "This server does not have any tracks";
+    const 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
+    let managed = false;
     for (const element of tracks) {
-        if (!element.track.manageableBy) continue
-        if (!element.track.manageableBy.some(role => member.roles.cache.has(role))) continue
+        if (!element.track.manageableBy) continue;
+        if (!element.track.manageableBy.some(role => member.roles.cache.has(role))) continue;
         managed = true;
         break;
-    };
+    }
     // Check if the user has manage_roles permission
     if (!managed && ! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
     // Allow track
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index bd71fe4..f7e66b8 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,19 +1,21 @@
-import { CommandInteraction } from "discord.js";
+import type { CommandInteraction } from "discord.js";
 import { SlashCommandBuilder } from "@discordjs/builders";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
 import { WrappedCheck } from "jshaiku";
 import verify from "../reflex/verify.js";
 
 const command = new SlashCommandBuilder()
     .setName("verify")
-    .setDescription("Get verified in the server")
+    .setDescription("Get verified in the server");
 
-const callback = async (interaction: CommandInteraction): Promise<any> => {
+const callback = async (interaction: CommandInteraction): Promise<void> => {
     verify(interaction);
-}
+};
 
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
     return true;
-}
+};
 
 export { command };
 export { callback };
diff --git a/src/config/format.js b/src/config/format.js
deleted file mode 100644
index bdd3fdb..0000000
--- a/src/config/format.js
+++ /dev/null
@@ -1,102 +0,0 @@
-import fs from 'fs';
-import * as readLine from 'node:readline/promises';
-import { exec } from 'node:child_process';
-
-const defaultDict = {
-    "developmentToken": "Your development bot token (Used for testing in one server, rather than production)",
-    "developmentGuildID": "Your development guild ID",
-    "enableDevelopment": true,
-    "token": "Your bot token",
-    "managementGuildID": "Your management guild ID (Used for running management commands on the bot)",
-    "owners": [],
-    "verifySecret": "If using verify, enter a code here which matches the secret sent back by your website. You can use a random code if you do not have one already. (Optional)",
-    "mongoUrl": "Your Mongo connection string, e.g. mongodb://127.0.0.1:27017",
-    "baseUrl": "Your website where buttons such as Verify and Role menu will link to, e.g. https://example.com",
-    "pastebinApiKey": "An API key for pastebin (optional)",
-    "pastebinUsername": "Your pastebin username (optional)",
-    "pastebinPassword": "Your pastebin password (optional)",
-}
-
-const readline = readLine.createInterface({
-    input: process.stdin,
-    output: process.stdout,
-});
-
-async function getInput(prompt) {
-    process.stdout.write(prompt);
-
-    const answer = await readline.question(prompt);
-    return answer.toString();
-}
-
-
-export default async function(walkthrough = false) {
-    if (walkthrough) {
-        console.log("\x1b[33m🛈  Entering walkthrough mode for any missing values.");
-        console.log("   \x1b[2mIf you don't want to enter a value, just hit enter.\x1b[0m\n");
-
-        // let toUse = await getInput("\x1b[36m[Installing packages] Use Yarn or NPM? \x1b[0m(\x1b[32my\x1b[0m/\x1b[31mN\x1b[0m) > ");
-        // toUse = toUse.toLowerCase() === "y" ? "yarn install" : "npm i";
-        // if ((await getInput(`\x1b[36m[Installing packages] Run ${toUse}? \x1b[0m(\x1b[32mY\x1b[0m/\x1b[31mn\x1b[0m) > `)).toLowerCase() !== "n") {
-        //     console.log(`\x1b[32m[Installing packages] Running ${toUse}...\x1b[0m`);
-        //     await exec(toUse);
-        //     console.log(`\x1b[32m[Installing packages] Installed\x1b[0m`);
-        // } else {
-        //     console.log("\x1b[32m[Installing packages] Skipping...\x1b[0m");
-        // }
-    }
-
-    let json;
-    let out = true
-    try {
-        json = JSON.parse(fs.readFileSync('./src/config/main.json', 'utf8'));
-    } catch (e) {
-        console.log("\x1b[31m⚠ No main.json found, creating one.")
-        console.log("  \x1b[2mYou can edit src/config/main.json directly using template written to the file.\x1b[0m\n")
-        out = false
-        json = {}
-    }
-    for (const key in defaultDict) {
-        if (!json[key]) {
-            if (walkthrough) {
-                switch (key) {
-                    case "enableDevelopment": {
-                        json[key] = (await getInput("\x1b[36mEnable development mode? This redisters commands in a single server making it easier to test\x1b[0m(\x1b[32mY\x1b[0m/\x1b[31mn\x1b[0m) > ") || "Y").toLowerCase() === "y"; break;
-                    } case "owners": {
-                        let chosen = "!";
-                        let toWrite = []
-                        while (chosen !== "") {
-                            chosen = await getInput("\x1b[36mEnter an owner ID \x1b[0m(\x1b[35mleave blank to finish\x1b[0m) > ");
-                            if (chosen !== "") { toWrite.push(chosen); }
-                        }
-                        json[key] = toWrite; break;
-                    } default: {
-                        json[key] = await getInput(`\x1b[36m${key} \x1b[0m(\x1b[35m${defaultDict[key]}\x1b[0m) > `);
-                    }
-                }
-            }
-            else { json[key] = defaultDict[key] }
-        }
-    }
-    if (walkthrough && !json.mongoUrl) json.mongoUrl = "mongodb://127.0.0.1:27017"
-    if (!json.mongoUrl.endsWith("/")) json.mongoUrl += "/";
-    if (!json.baseUrl.endsWith("/")) json.baseUrl += "/";
-    let hosts;
-    try {
-        hosts = fs.readFileSync('/etc/hosts', 'utf8').toString().split("\n");
-    } catch (e) {
-        return console.log("\x1b[31m⚠ No /etc/hosts found. Please ensure the file exists and is readable. (Windows is not supported, Mac and Linux users should not experience this error)")
-    }
-    let localhost = hosts.find(line => line.split(" ")[1] === "localhost");
-    if (localhost) { localhost = localhost.split(" ")[0]; }
-    else { localhost = "127.0.0.1" }
-    json.mongoUrl = json.mongoUrl.replace("localhost", localhost);
-    json.baseUrl = json.baseUrl.replace("localhost", localhost);
-
-    fs.writeFileSync("./src/config/main.json", JSON.stringify(json, null, 4))
-
-    if (walkthrough) {
-        console.log("\x1b[32m✓ All properties added.\x1b[0m")
-    }
-    return out;
-}
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index fa66755..c4c1347 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -1,71 +1,70 @@
-export const event = 'channelCreate'
+export const event = "channelCreate";
 
 export async function callback(client, channel) {
-    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 emoji;
-        let readableType;
-        let displayName;
-        switch (channel.type) {
-            case 'GUILD_TEXT': {
-                emoji = "CHANNEL.TEXT.CREATE";
-                readableType = "Text";
-                displayName = "Text Channel"
-                break;
-            }
-            case 'GUILD_NEWS': {
-                emoji = "CHANNEL.TEXT.CREATE";
-                readableType = "Announcement";
-                displayName = "Announcement Channel"
-                break;
-            }
-            case 'GUILD_VOICE': {
-                emoji = "CHANNEL.VOICE.CREATE";
-                readableType = "Voice";
-                displayName = "Voice Channel"
-                break;
-            }
-            case 'GUILD_STAGE': {
-                emoji = "CHANNEL.VOICE.CREATE";
-                readableType = "Stage";
-                displayName = "Stage Channel"
-            }
-            case 'GUILD_CATEGORY': {
-                emoji = "CHANNEL.CATEGORY.CREATE";
-                readableType = "Category";
-                displayName = "Category"
-                break;
-            }
-            default: {
-                emoji = "CHANNEL.TEXT.CREATE";
-                readableType = "Channel";
-                displayName = "Channel"
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger;
+    const auditLog = await getAuditLog(channel.guild, "CHANNEL_CREATE");
+    const 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;
+    switch (channel.type) {
+    case "GUILD_TEXT": {
+        emoji = "CHANNEL.TEXT.CREATE";
+        readableType = "Text";
+        displayName = "Text Channel";
+        break;
+    }
+    case "GUILD_NEWS": {
+        emoji = "CHANNEL.TEXT.CREATE";
+        readableType = "Announcement";
+        displayName = "Announcement Channel";
+        break;
+    }
+    case "GUILD_VOICE": {
+        emoji = "CHANNEL.VOICE.CREATE";
+        readableType = "Voice";
+        displayName = "Voice Channel";
+        break;
+    }
+    case "GUILD_STAGE": {
+        emoji = "CHANNEL.VOICE.CREATE";
+        readableType = "Stage";
+        displayName = "Stage Channel";
+        break;
+    }
+    case "GUILD_CATEGORY": {
+        emoji = "CHANNEL.CATEGORY.CREATE";
+        readableType = "Category";
+        displayName = "Category";
+        break;
+    }
+    default: {
+        emoji = "CHANNEL.TEXT.CREATE";
+        readableType = "Channel";
+        displayName = "Channel";
+    }
+    }
+    const data = {
+        meta: {
+            type: "channelCreate",
+            displayName: displayName + " Created",
+            calculateType: "channelUpdate",
+            color: NucleusColors.green,
+            emoji: emoji,
+            timestamp: channel.createdTimestamp
+        },
+        list: {
+            channelId: entry(channel.id, `\`${channel.id}\``),
+            name: entry(channel.name, renderChannel(channel)),
+            type: entry(channel.type, readableType),
+            category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
+        },
+        hidden: {
+            guild: channel.guild.id
         }
-        let data = {
-            meta: {
-                type: 'channelCreate',
-                displayName: displayName + ' Created',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.green,
-                emoji: emoji,
-                timestamp: channel.createdTimestamp
-            },
-            list: {
-                channelId: entry(channel.id, `\`${channel.id}\``),
-                name: entry(channel.name, renderChannel(channel)),
-                type: entry(channel.type, readableType),
-                category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
-            },
-            hidden: {
-                guild: channel.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index 25c9ce5..c8a72a4 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -1,73 +1,71 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'channelDelete'
+export const event = "channelDelete";
 
 export async function callback(client, channel) {
-    try{
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
+    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;
+    const auditLog = await getAuditLog(channel.guild, "CHANNEL_DELETE");
+    const 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;
-        switch (channel.type) {
-            case 'GUILD_TEXT': {
-                emoji = "CHANNEL.TEXT.DELETE";
-                readableType = "Text";
-                displayName = "Text Channel"
-                break;
-            }
-            case 'GUILD_VOICE': {
-                emoji = "CHANNEL.VOICE.DELETE";
-                readableType = "Voice";
-                displayName = "Voice Channel"
-                break;
-            }
-            case 'GUILD_CATEGORY': {
-                emoji = "CHANNEL.CATEGORY.DELETE";
-                readableType = "Category";
-                displayName = "Category"
-                break;
-            }
-            default: {
-                emoji = "CHANNEL.TEXT.DELETE";
-                readableType = "Channel";
-                displayName = "Channel"
-            }
-        }
-        let list = {
-            channelId: entry(channel.id, `\`${channel.id}\``),
-            name: entry(channel.id, `${channel.name}`),
-            topic: null,
-            type: entry(channel.type, readableType),
-            category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
-            nsfw: null,
-            created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
-            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\`\`\``);
-        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;
+    let emoji;
+    let readableType;
+    let displayName;
+    switch (channel.type) {
+    case "GUILD_TEXT": {
+        emoji = "CHANNEL.TEXT.DELETE";
+        readableType = "Text";
+        displayName = "Text Channel";
+        break;
+    }
+    case "GUILD_VOICE": {
+        emoji = "CHANNEL.VOICE.DELETE";
+        readableType = "Voice";
+        displayName = "Voice Channel";
+        break;
+    }
+    case "GUILD_CATEGORY": {
+        emoji = "CHANNEL.CATEGORY.DELETE";
+        readableType = "Category";
+        displayName = "Category";
+        break;
+    }
+    default: {
+        emoji = "CHANNEL.TEXT.DELETE";
+        readableType = "Channel";
+        displayName = "Channel";
+    }
+    }
+    const list = {
+        channelId: entry(channel.id, `\`${channel.id}\``),
+        name: entry(channel.id, `${channel.name}`),
+        topic: null,
+        type: entry(channel.type, readableType),
+        category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+        nsfw: null,
+        created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+        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\`\`\``);
+    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;
 
-        let data = {
-            meta:{
-                type: 'channelDelete',
-                displayName: displayName + ' Deleted',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.red,
-                emoji: emoji,
-                timestamp: audit.createdTimestamp
-            },
-            list: list,
-            hidden: {
-                guild: channel.guild.id
-            }
+    const data = {
+        meta:{
+            type: "channelDelete",
+            displayName: displayName + " Deleted",
+            calculateType: "channelUpdate",
+            color: NucleusColors.red,
+            emoji: emoji,
+            timestamp: audit.createdTimestamp
+        },
+        list: list,
+        hidden: {
+            guild: channel.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 568af0b..89692e8 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -1,135 +1,133 @@
-import humanizeDuration from 'humanize-duration';
-import getEmojiByName from '../utils/getEmojiByName.js';
+import humanizeDuration from "humanize-duration";
+import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'channelUpdate';
+export const event = "channelUpdate";
 
 export async function callback(client, oc, nc) {
-    try {
-        let config = await client.memory.readGuildInfo(nc.guild.id);
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
+    const 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;
+    const auditLog = await getAuditLog(nc.guild, "CHANNEL_UPDATE");
+    const 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;
-        let displayName:string ;
-        let changes = {
-            channelId: entry(nc.id, `\`${nc.id}\``),
-            channel: entry(nc.id, renderChannel(nc)),
-            edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
+    let emoji:string;
+    let readableType:string;
+    let displayName:string ;
+    const changes = {
+        channelId: entry(nc.id, `\`${nc.id}\``),
+        channel: entry(nc.id, renderChannel(nc)),
+        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}`);
+
+    switch (nc.type) {
+    case "GUILD_TEXT": {
+        emoji = "CHANNEL.TEXT.EDIT";
+        readableType = "Text";
+        displayName = "Text Channel";
+        let oldTopic = oc.topic, newTopic = nc.topic;
+        if (oldTopic) {
+            if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+        } else { oldTopic = "None"; }
+        if (newTopic) {
+            if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+        } else { newTopic = "None"; }
+        const 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(
+            [oc.rateLimitPerUser, nc.rateLimitPerUser],
+            `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
+        );
+
+        break;
+    }
+    case "GUILD_NEWS": {
+        emoji = "CHANNEL.TEXT.EDIT";
+        readableType = "News";
+        displayName = "News Channel";
+        let oldTopic = oc.topic, newTopic = nc.topic;
+        if (oldTopic) {
+            if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+        } else { oldTopic = "None"; }
+        if (newTopic) {
+            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"}`);
+        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(
+            [oc.rtcRegion, nc.rtcRegion],
+            `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+        );
+        break;
+    }
+    case "GUILD_STAGE": {
+        emoji = "CHANNEL.VOICE.EDIT";
+        readableType = "Stage";
+        displayName = "Stage Channel";
+        let oldTopic = oc.topic, newTopic = nc.topic;
+        if (oldTopic) {
+            if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+            else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+        } else { oldTopic = "None"; }
+        if (newTopic) {
+            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(
+            [oc.rtcRegion, nc.rtcRegion],
+            `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+        );
+        break;
+    }
+    case "GUILD_CATEGORY": {
+        emoji = "CHANNEL.CATEGORY.EDIT";
+        readableType = "Category";
+        displayName = "Category";
+        break;
+    }
+    default: {
+        emoji = "CHANNEL.TEXT.EDIT";
+        readableType = "Channel";
+        displayName = "Channel";
+    }
+    }
+    const 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 (!(Object.values(changes).length - 4)) return;
+    const data = {
+        meta:{
+            type: "channelUpdate",
+            displayName: displayName + " Edited",
+            calculateType: "channelUpdate",
+            color: NucleusColors.yellow,
+            emoji: emoji,
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: nc.guild.id
         }
-        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': {
-                emoji = "CHANNEL.TEXT.EDIT";
-                readableType = "Text";
-                displayName = "Text Channel"
-                let oldTopic = oc.topic, newTopic = nc.topic;
-                if (oldTopic) {
-                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-                } else { oldTopic = "None"; }
-                if (newTopic) {
-                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-                } else { newTopic = "None"; }
-                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(
-                    [oc.rateLimitPerUser, nc.rateLimitPerUser],
-                    `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
-                );
-
-                break;
-            }
-            case 'GUILD_NEWS': {
-                emoji = "CHANNEL.TEXT.EDIT";
-                readableType = "News";
-                displayName = "News Channel"
-                let oldTopic = oc.topic, newTopic = nc.topic;
-                if (oldTopic) {
-                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-                } else { oldTopic = "None"; }
-                if (newTopic) {
-                    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"}`);
-                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(
-                    [oc.rtcRegion, nc.rtcRegion],
-                    `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
-                );
-                break;
-            }
-            case 'GUILD_STAGE': {
-                emoji = "CHANNEL.VOICE.EDIT";
-                readableType = "Stage";
-                displayName = "Stage Channel"
-                let oldTopic = oc.topic, newTopic = nc.topic;
-                if (oldTopic) {
-                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-                } else { oldTopic = "None"; }
-                if (newTopic) {
-                    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(
-                    [oc.rtcRegion, nc.rtcRegion],
-                    `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
-                );
-                break;
-            }
-            case 'GUILD_CATEGORY': {
-                emoji = "CHANNEL.CATEGORY.EDIT";
-                readableType = "Category";
-                displayName = "Category"
-                break;
-            }
-            default: {
-                emoji = "CHANNEL.TEXT.EDIT";
-                readableType = "Channel";
-                displayName = "Channel"
-            }
-        }
-        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 (!(Object.values(changes).length - 4)) return
-        let data = {
-            meta:{
-                type: 'channelUpdate',
-                displayName: displayName + ' Edited',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.yellow,
-                emoji: emoji,
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: nc.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/commandError.ts b/src/events/commandError.ts
index 8edb480..2ec6a5d 100644
--- a/src/events/commandError.ts
+++ b/src/events/commandError.ts
@@ -1,6 +1,6 @@
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 
-export const event = 'commandError'
+export const event = "commandError";
 
 export async function callback(client, interaction, error) {
     if (interaction.replied || interaction.deferred) {
@@ -9,13 +9,13 @@
             .setDescription(error.message ?? error.toString())
             .setStatus("Danger")
             .setEmoji("CONTROL.BLOCKCROSS")
-        ], ephemeral: true})
+        ], ephemeral: true});
     } else {
         await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Something went wrong")
             .setDescription(error.message ?? error.toString())
             .setStatus("Danger")
             .setEmoji("CONTROL.BLOCKCROSS")
-        ], ephemeral: true})
+        ], ephemeral: true});
     }
 }
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 9e91012..83a30e2 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,30 +1,28 @@
-export const event = 'emojiCreate'
+export const event = "emojiCreate";
 
 export async function callback(client, emoji) {
-    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 data = {
-            meta: {
-                type: 'emojiCreate',
-                displayName: 'Emoji Created',
-                calculateType: 'emojiUpdate',
-                color: NucleusColors.green,
-                emoji: "GUILD.EMOJI.CREATE",
-                timestamp: emoji.createdTimestamp
-            },
-            list: {
-                emojiId: entry(emoji.id, `\`${emoji.id}\``),
-                emoji: entry(emoji.name, renderEmoji(emoji)),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "EMOJI_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "emojiCreate",
+            displayName: "Emoji Created",
+            calculateType: "emojiUpdate",
+            color: NucleusColors.green,
+            emoji: "GUILD.EMOJI.CREATE",
+            timestamp: emoji.createdTimestamp
+        },
+        list: {
+            emojiId: entry(emoji.id, `\`${emoji.id}\``),
+            emoji: entry(emoji.name, renderEmoji(emoji)),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 0c39542..5ed7a87 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,31 +1,29 @@
-export const event = 'emojiDelete'
+export const event = "emojiDelete";
 
 export async function callback(client, emoji) {
-    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 data = {
-            meta: {
-                type: 'emojiDelete',
-                displayName: 'Emoji Deleted',
-                calculateType: 'emojiUpdate',
-                color: NucleusColors.red,
-                emoji: "GUILD.EMOJI.DELETE",
-                timestamp: audit.createdTimestamp,
-            },
-            list: {
-                emojiId: entry(emoji.id, `\`${emoji.id}\``),
-                emoji: entry(emoji.name, renderEmoji(emoji)),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
-                deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "EMOJI_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "emojiDelete",
+            displayName: "Emoji Deleted",
+            calculateType: "emojiUpdate",
+            color: NucleusColors.red,
+            emoji: "GUILD.EMOJI.DELETE",
+            timestamp: audit.createdTimestamp
+        },
+        list: {
+            emojiId: entry(emoji.id, `\`${emoji.id}\``),
+            emoji: entry(emoji.name, renderEmoji(emoji)),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+            deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index a90de9a..d04c6c8 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -1,37 +1,33 @@
-import getEmojiByName from "../utils/getEmojiByName.js";
-
-export const event = 'emojiUpdate';
+export const event = "emojiUpdate";
 
 export async function callback(client, oe, ne) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger;
 
-        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 (oe.name === ne.name) return;
+    const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
+    const audit = auditLog.entries.first();
+    if (audit.executor.id === client.user.id) return;
 
-        let changes = {
-            emojiId: entry(ne.id, `\`${ne.id}\``),
-            emoji: entry(ne.id, renderEmoji(ne)),
-            edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
-            editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
-            name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+    const changes = {
+        emojiId: entry(ne.id, `\`${ne.id}\``),
+        emoji: entry(ne.id, renderEmoji(ne)),
+        edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+        editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+        name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
+    };
+    const data = {
+        meta:{
+            type: "emojiUpdate",
+            displayName: "Emoji Edited",
+            calculateType: "emojiUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.EMOJI.EDIT",
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: ne.guild.id
         }
-        let data = {
-            meta:{
-                type: 'emojiUpdate',
-                displayName: 'Emoji Edited',
-                calculateType: 'emojiUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.EMOJI.EDIT",
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: ne.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index 06163a9..c5d269b 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -1,39 +1,37 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildBanAdd';
+export const event = "guildBanAdd";
 
 export async function callback(client, ban) {
-    try { await statsChannelRemove(client, ban.user); } catch {}
-    try { purgeByUser(ban.user.id, ban.guild); } catch {}
-    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
-        try { await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
-        let data = {
-            meta: {
-                type: 'memberBan',
-                displayName: 'Member Banned',
-                calculateType: 'guildMemberPunish',
-                color: NucleusColors.red,
-                emoji: "PUNISH.BAN.RED",
-                timestamp: new Date().getTime()
-            },
-            list: {
-                memberId: entry(ban.user.id, `\`${ban.user.id}\``),
-                name: entry(ban.user.id, renderUser(ban.user)),
-                banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
-                accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
-                serverMemberCount: ban.guild.memberCount,
-            },
-            hidden: {
-                guild: ban.guild.id
-            }
+    await statsChannelRemove(client, ban.user);
+    purgeByUser(ban.user.id, ban.guild);
+    const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+    const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_ADD");
+    const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+    if (audit.executor.id === client.user.id) return;
+    await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason);
+    const data = {
+        meta: {
+            type: "memberBan",
+            displayName: "Member Banned",
+            calculateType: "guildMemberPunish",
+            color: NucleusColors.red,
+            emoji: "PUNISH.BAN.RED",
+            timestamp: new Date().getTime()
+        },
+        list: {
+            memberId: entry(ban.user.id, `\`${ban.user.id}\``),
+            name: entry(ban.user.id, renderUser(ban.user)),
+            banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+            bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+            accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
+            serverMemberCount: ban.guild.memberCount
+        },
+        hidden: {
+            guild: ban.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 2a1b6de..352265f 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -1,38 +1,35 @@
-import humanizeDuration from 'humanize-duration';
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildBanRemove';
+export const event = "guildBanRemove";
 
 export async function callback(client, ban) {
-    try { await statsChannelRemove(client, ban.user); } catch {}
-    try { purgeByUser(ban.user.id, ban.guild); } catch {}
-    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
-        try { await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
-        let data = {
-            meta: {
-                type: 'memberUnban',
-                displayName: 'Member Unbanned',
-                calculateType: 'guildMemberPunish',
-                color: NucleusColors.green,
-                emoji: "PUNISH.BAN.GREEN",
-                timestamp: new Date().getTime()
-            },
-            list: {
-                memberId: entry(ban.user.id, `\`${ban.user.id}\``),
-                name: entry(ban.user.id, renderUser(ban.user)),
-                unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
-            },
-            hidden: {
-                guild: ban.guild.id
-            }
+    await statsChannelRemove(client, ban.user);
+    purgeByUser(ban.user.id, ban.guild);
+    const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+    const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_REMOVE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+    if (audit.executor.id === client.user.id) return;
+    await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason);
+    const data = {
+        meta: {
+            type: "memberUnban",
+            displayName: "Member Unbanned",
+            calculateType: "guildMemberPunish",
+            color: NucleusColors.green,
+            emoji: "PUNISH.BAN.GREEN",
+            timestamp: new Date().getTime()
+        },
+        list: {
+            memberId: entry(ban.user.id, `\`${ban.user.id}\``),
+            name: entry(ban.user.id, renderUser(ban.user)),
+            unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+            unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt))
+        },
+        hidden: {
+            guild: ban.guild.id
         }
-        log(data);
-    } catch (e) {console.log(e)}
+    };
+    log(data);
 }
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index 413e5fb..8f8d0f5 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,12 +1,11 @@
-import { MessageActionRow, MessageButton } from "discord.js";
-import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../utils/getEmojiByName.js";
+import type { Guild } from "discord.js";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { HaikuClient } from "jshaiku";
 import guide from "../reflex/guide.js";
 
-export const event = 'guildCreate';
+export const event = "guildCreate";
 
-export async function callback(client, guild) {
-    try{
-        guide(guild)
-    } catch {}
+export async function callback(_client: HaikuClient, guild: Guild) {
+    guide(guild);
 }
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index d555647..a7f8c47 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -1,20 +1,20 @@
-export const event = 'guildMemberUpdate'
+export const event = "guildMemberUpdate";
 
 export async function callback(client, before, after) {
     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();
+        const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger;
+        const auditLog = await getAuditLog(after.guild, "MEMBER_UPDATE");
+        const 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(
+            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 {}
-            let data = {
+                null, before.nickname || before.user.username, after.nickname || after.user.username);
+            const data = {
                 meta: {
-                    type: 'memberUpdate',
-                    displayName: 'Nickname Changed',
-                    calculateType: 'guildMemberUpdate',
+                    type: "memberUpdate",
+                    displayName: "Nickname Changed",
+                    calculateType: "guildMemberUpdate",
                     color: NucleusColors.yellow,
                     emoji: "PUNISH.NICKNAME.YELLOW",
                     timestamp: new Date().getTime()
@@ -22,25 +22,25 @@
                 list: {
                     memberId: entry(after.id, `\`${after.id}\``),
                     name: entry(after.user.id, renderUser(after.user)),
-                    before: entry(before.nickname, before.nickname ? before.nickname : '*None*'),
-                    after: entry(after.nickname, after.nickname ? after.nickname : '*None*'),
+                    before: entry(before.nickname, before.nickname ? before.nickname : "*None*"),
+                    after: entry(after.nickname, after.nickname ? after.nickname : "*None*"),
                     changed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     changedBy: entry(audit.executor.id, renderUser(audit.executor))
                 },
                 hidden: {
                     guild: after.guild.id
                 }
-            }
+            };
             log(data);
         } else if (before.communicationDisabledUntilTimestamp < new Date().getTime() && after.communicationDisabledUntil > new Date().getTime()) {
-            try { await client.database.history.create(
+            await client.database.history.create(
                 "mute", after.guild.id, after.user, audit.executor, audit.reason, null, null, null
-            )} catch {}
-            let data = {
+            );
+            const data = {
                 meta: {
-                    type: 'memberMute',
-                    displayName: 'Muted',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberMute",
+                    displayName: "Muted",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.yellow,
                     emoji: "PUNISH.MUTE.YELLOW",
                     timestamp: new Date().getTime()
@@ -51,12 +51,12 @@
                     mutedUntil: entry(after.communicationDisabledUntilTimestamp, renderDelta(after.communicationDisabledUntilTimestamp)),
                     muted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
                     mutedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                    reason: entry(audit.reason, audit.reason ? audit.reason : '\n> *No reason provided*')
+                    reason: entry(audit.reason, audit.reason ? audit.reason : "\n> *No reason provided*")
                 },
                 hidden: {
                     guild: after.guild.id
                 }
-            }
+            };
             log(data);
             client.database.eventScheduler.schedule("naturalUnmute", after.communicationDisabledUntil,
                 {guild: after.guild.id, user: after.id, expires: after.communicationDisabledUntilTimestamp}
@@ -65,14 +65,14 @@
             after.communicationDisabledUntil === null && before.communicationDisabledUntilTimestamp !== null &&
             new Date().getTime() >= audit.createdTimestamp
         ) {
-            try { await client.database.history.create(
+            await client.database.history.create(
                 "unmute", after.guild.id, after.user, audit.executor, null, null, null, null
-            )} catch {}
-            let data = {
+            );
+            const data = {
                 meta: {
-                    type: 'memberUnmute',
-                    displayName: 'Unmuted',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberUnmute",
+                    displayName: "Unmuted",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.green,
                     emoji: "PUNISH.MUTE.GREEN",
                     timestamp: new Date().getTime()
@@ -86,9 +86,9 @@
                 hidden: {
                     guild: after.guild.id
                 }
-            }
+            };
             log(data);
             client.database.eventScheduler.cancel("naturalUnmute", {guild: after.guild.id, user: after.id, expires: before.communicationDisabledUntilTimestamp});
         }
-    } catch (e) { console.log(e) }
+    } catch (e) { console.log(e); }
 }
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index e27975b..2cb1de8 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,61 +1,59 @@
-import { callback as statsChannelUpdate } from '../reflex/statsChannelUpdate.js';
+import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildUpdate'
+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 list = {}
+    await statsChannelUpdate(client, after.me);
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
+    const auditLog = await getAuditLog(after, "GUILD_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const list = {};
 
-        const verificationLevels = {
-            NONE: 'Unrestricted',
-            LOW: 'Verified email',
-            MEDIUM: 'Registered (5 minutes)',
-            HIGH: 'Member (10 minutes)',
-            VERY_HIGH: 'Verified phone'
+    const verificationLevels = {
+        NONE: "Unrestricted",
+        LOW: "Verified email",
+        MEDIUM: "Registered (5 minutes)",
+        HIGH: "Member (10 minutes)",
+        VERY_HIGH: "Verified phone"
+    };
+
+    const explicitContentFilterLevels = {
+        DISABLED: "Disabled",
+        MEMBERS_WITHOUT_ROLES: "Members without roles",
+        ALL_MEMBERS: "All members"
+    };
+
+    const MFALevels = {
+        NONE: "None",
+        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 (!(Object.keys(list).length)) return;
+    list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+    list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+    const data = {
+        meta: {
+            type: "guildUpdate",
+            displayName: "Guild Edited",
+            calculateType: "guildUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.YELLOW",
+            timestamp: new Date().getTime()
+        },
+        list: list,
+        hidden: {
+            guild: after.id
         }
-
-        const explicitContentFilterLevels = {
-            DISABLED: 'Disabled',
-            MEMBERS_WITHOUT_ROLES: 'Members without roles',
-            ALL_MEMBERS: 'All members'
-        }
-
-        const MFALevels = {
-            NONE: 'None',
-            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 (!(Object.keys(list).length)) return;
-        list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
-        list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
-        let data = {
-            meta: {
-                type: 'guildUpdate',
-                displayName: 'Guild Edited',
-                calculateType: 'guildUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.YELLOW",
-                timestamp: new Date().getTime()
-            },
-            list: list,
-            hidden: {
-                guild: after.id
-            }
-        }
-        log(data);
-    } catch (e) {}
+    };
+    log(data);
 }
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index a4bb8c3..08fcc77 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -1,57 +1,56 @@
-import { callback as roleMenu } from "../actions/roleMenu.js"
+import { callback as roleMenu } from "../actions/roleMenu.js";
 import verify from "../reflex/verify.js";
 import create from "../actions/tickets/create.js";
 import close from "../actions/tickets/delete.js";
 import createTranscript from "../premium/createTranscript.js";
 import Fuse from "fuse.js";
-import { autocomplete as tagAutocomplete } from "../commands/tag.js"
+import { autocomplete as tagAutocomplete } from "../commands/tag.js";
 
-export const event = 'interactionCreate';
+export const event = "interactionCreate";
 
 
 function getAutocomplete(typed: string, options: string[]): object[] {
-    options = options.filter(option => option.length <= 100) // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
-    if (!typed) return options.slice(0, 25).sort().map(option => ({name: option, value: option}))
-    const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed)
-    return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}))
+    options = options.filter(option => option.length <= 100); // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
+    if (!typed) return options.slice(0, 25).sort().map(option => ({name: option, value: option}));
+    const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed);
+    return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}));
 }
 
 function generateStatsChannelAutocomplete(typed) {
-    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"]
-    let autocompletions = []
-    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
-    if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
-    else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
-    return getAutocomplete(typed, autocompletions)
+    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"];
+    const autocompletions = [];
+    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+    if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+    else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+    return getAutocomplete(typed, autocompletions);
 }
 function generateWelcomeMessageAutocomplete(typed) {
-    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"]
-    let autocompletions = []
-    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
-    if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
-    else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
-    return getAutocomplete(typed, autocompletions)
+    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"];
+    const autocompletions = [];
+    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+    if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+    else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+    return getAutocomplete(typed, autocompletions);
 }
 
 async function interactionCreate(interaction) {
     if (interaction.componentType === "BUTTON") {
         switch (interaction.customId) {
-            case "rolemenu": { return await roleMenu(interaction) }
-            case "verifybutton": { return verify(interaction) }
-            case "createticket": { return create(interaction) }
-            case "closeticket": { return close(interaction) }
-            case "createtranscript": { return createTranscript(interaction) }
+        case "rolemenu": { return await roleMenu(interaction); }
+        case "verifybutton": { return verify(interaction); }
+        case "createticket": { return create(interaction); }
+        case "closeticket": { return close(interaction); }
+        case "createtranscript": { return createTranscript(interaction); }
         }
-    } else if (interaction.componentType === "MESSAGE_COMPONENT") {
     } else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
         switch (`${interaction.commandName} ${interaction.options.getSubcommandGroup(false)} ${interaction.options.getSubcommand(false)}`) {
-            case `tag null null`: { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))) }
-            case `settings null stats`: { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))) }
-            case `settings null welcome`: { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))) }
+        case "tag null null": { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))); }
+        case "settings null stats": { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))); }
+        case "settings null welcome": { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))); }
         }
     }
 }
 
 export async function callback(client, interaction) {
-    await interactionCreate(interaction)
+    await interactionCreate(interaction);
 }
\ No newline at end of file
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 5d47bf8..1cbed02 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -1,32 +1,30 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'inviteCreate'
+import humanizeDuration from "humanize-duration";
+export const event = "inviteCreate";
 
 export async function callback(client, invite) {
-    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 data = {
-            meta: {
-                type: 'inviteCreate',
-                displayName: 'Invite Created',
-                calculateType: 'guildUpdate',
-                color: NucleusColors.green,
-                emoji: "INVITE.CREATE",
-                timestamp: invite.createdTimestamp
-            },
-            list: {
-                channel: entry(invite.channel.id, renderChannel(invite.channel)),
-                link: entry(invite.url, invite.url),
-                expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
-            },
-            hidden: {
-                guild: invite.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+    const auditLog = await getAuditLog(invite.guild, "INVITE_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "inviteCreate",
+            displayName: "Invite Created",
+            calculateType: "guildUpdate",
+            color: NucleusColors.green,
+            emoji: "INVITE.CREATE",
+            timestamp: invite.createdTimestamp
+        },
+        list: {
+            channel: entry(invite.channel.id, renderChannel(invite.channel)),
+            link: entry(invite.url, invite.url),
+            expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
+        },
+        hidden: {
+            guild: invite.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index acfc9dd..cbe4d4b 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -1,32 +1,30 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'inviteDelete'
+import humanizeDuration from "humanize-duration";
+export const event = "inviteDelete";
 
 export async function callback(client, invite) {
-    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 data = {
-            meta: {
-                type: 'inviteDelete',
-                displayName: 'Invite Deleted',
-                calculateType: 'guildUpdate',
-                color: NucleusColors.red,
-                emoji: "INVITE.DELETE",
-                timestamp: new Date().getTime()
-            },
-            list: {
-                channel: entry(invite.channel.id, renderChannel(invite.channel)),
-                link: entry(invite.url, invite.url),
-                expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
-            },
-            hidden: {
-                guild: invite.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+    const auditLog = await getAuditLog(invite.guild, "INVITE_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "inviteDelete",
+            displayName: "Invite Deleted",
+            calculateType: "guildUpdate",
+            color: NucleusColors.red,
+            emoji: "INVITE.DELETE",
+            timestamp: new Date().getTime()
+        },
+        list: {
+            channel: entry(invite.channel.id, renderChannel(invite.channel)),
+            link: entry(invite.url, invite.url),
+            expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+        },
+        hidden: {
+            guild: invite.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 109f226..34545fb 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -1,36 +1,33 @@
-import { callback as statsChannelAdd } from '../reflex/statsChannelUpdate.js';
-import { callback as welcome } from '../reflex/welcome.js';
-import log from '../utils/log.js';
-import client from '../utils/client.js';
+import { callback as statsChannelAdd } from "../reflex/statsChannelUpdate.js";
+import { callback as welcome } from "../reflex/welcome.js";
+import client from "../utils/client.js";
 
-export const event = 'guildMemberAdd'
+export const event = "guildMemberAdd";
 
 export async function callback(_, member) {
-    try { welcome(_, member); } catch {}
-    try { statsChannelAdd(_, member, ); } catch {}
-    try {
-        const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
-        try { await client.database.history.create("join", member.guild.id, member.user, null, null) } catch {}
-        let data = {
-            meta: {
-                type: 'memberJoin',
-                displayName: 'Member Joined',
-                calculateType: 'guildMemberUpdate',
-                color: NucleusColors.green,
-                emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
-                timestamp: member.joinedTimestamp
-            },
-            list: {
-                memberId: entry(member.id, `\`${member.id}\``),
-                name: entry(member.id, renderUser(member.user)),
-                joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
-                accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                serverMemberCount: member.guild.memberCount,
-            },
-            hidden: {
-                guild: member.guild.id
-            }
+    welcome(_, member);
+    statsChannelAdd(_, member );
+    const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+    await client.database.history.create("join", member.guild.id, member.user, null, null);
+    const data = {
+        meta: {
+            type: "memberJoin",
+            displayName: "Member Joined",
+            calculateType: "guildMemberUpdate",
+            color: NucleusColors.green,
+            emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
+            timestamp: member.joinedTimestamp
+        },
+        list: {
+            memberId: entry(member.id, `\`${member.id}\``),
+            name: entry(member.id, renderUser(member.user)),
+            joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+            accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+            serverMemberCount: member.guild.memberCount
+        },
+        hidden: {
+            guild: member.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 5dff86f..842a48b 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,72 +1,70 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
 
-export const event = 'guildMemberRemove'
+export const event = "guildMemberRemove";
 
 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 type = "leave"
-        if (audit) {
-            if (audit.executor.id === client.user.id) return
-            if (audit.createdAt - 100 >= new Date().getTime()) {
-                type = "kick"
-            }
+    purgeByUser(member.id, member.guild);
+    await statsChannelRemove(client, member);
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+    const auditLog = await getAuditLog(member.guild, "MEMBER_KICK");
+    const audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
+    let type = "leave";
+    if (audit) {
+        if (audit.executor.id === client.user.id) return;
+        if (audit.createdAt - 100 >= new Date().getTime()) {
+            type = "kick";
         }
-        let data
-        if (type === "kick") {
-            try { await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason) } catch {}
-            data = {
-                meta: {
-                    type: 'memberKick',
-                    displayName: 'Member Kicked',
-                    calculateType: 'guildMemberPunish',
-                    color: NucleusColors.red,
-                    emoji: "PUNISH.KICK.RED",
-                    timestamp: new Date().getTime()
-                },
-                list: {
-                    memberId: entry(member.id, `\`${member.id}\``),
-                    name: entry(member.id, renderUser(member.user)),
-                    joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
-                    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.*"),
-                    accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                    serverMemberCount: member.guild.memberCount,
-                },
-                hidden: {
-                    guild: member.guild.id
-                }
+    }
+    let data;
+    if (type === "kick") {
+        await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
+        data = {
+            meta: {
+                type: "memberKick",
+                displayName: "Member Kicked",
+                calculateType: "guildMemberPunish",
+                color: NucleusColors.red,
+                emoji: "PUNISH.KICK.RED",
+                timestamp: new Date().getTime()
+            },
+            list: {
+                memberId: entry(member.id, `\`${member.id}\``),
+                name: entry(member.id, renderUser(member.user)),
+                joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+                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.*"),
+                accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+                serverMemberCount: member.guild.memberCount
+            },
+            hidden: {
+                guild: member.guild.id
             }
-        } else {
-            try { await client.database.history.create("leave", member.guild.id, member.user, null, null) } catch {}
-            data = {
-                meta: {
-                    type: 'memberLeave',
-                    displayName: 'Member Left',
-                    calculateType: 'guildMemberUpdate',
-                    color: NucleusColors.red,
-                    emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
-                    timestamp: new Date().getTime()
-                },
-                list: {
-                    memberId: entry(member.id, `\`${member.id}\``),
-                    name: entry(member.id, renderUser(member.user)),
-                    joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
-                    left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                    accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
-                    serverMemberCount: member.guild.memberCount,
-                },
-                hidden: {
-                    guild: member.guild.id
-                }
+        };
+    } else {
+        await client.database.history.create("leave", member.guild.id, member.user, null, null);
+        data = {
+            meta: {
+                type: "memberLeave",
+                displayName: "Member Left",
+                calculateType: "guildMemberUpdate",
+                color: NucleusColors.red,
+                emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
+                timestamp: new Date().getTime()
+            },
+            list: {
+                memberId: entry(member.id, `\`${member.id}\``),
+                name: entry(member.id, renderUser(member.user)),
+                joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
+                left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+                accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+                serverMemberCount: member.guild.memberCount
+            },
+            hidden: {
+                guild: member.guild.id
             }
-        }
-        log(data);
-    } catch (e) { console.log(e) }
+        };
+    }
+    log(data);
 }
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index cbb1fa2..bbb6a32 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,28 +1,33 @@
-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 client from '../utils/client.js';
-import {callback as a} from '../reflex/statsChannelUpdate.js'
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import { HaikuClient } from "jshaiku";
+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 client from "../utils/client.js";
+import {callback as a} from "../reflex/statsChannelUpdate.js";
+import type { Message } from "discord.js";
 
-export const event = 'messageCreate'
+export const event = "messageCreate";
 
-export async function callback(_, message) {
+export async function callback(_client: HaikuClient, message: 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)}
+    if(!message.guild) 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
+    const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
 
-    let fileNames = await logAttachment(message);
+    const fileNames = await logAttachment(message);
 
-    let content = message.content.toLowerCase() || ''
-    let config = await client.memory.readGuildInfo(message.guild.id);
-    const filter = getEmojiByName("ICONS.FILTER")
-    let attachmentJump = ""
-    if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})` }
-    let list = {
+    const content = message.content.toLowerCase() || "";
+    const config = await client.memory.readGuildInfo(message.guild.id);
+    const filter = getEmojiByName("ICONS.FILTER");
+    let attachmentJump = "";
+    if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`; }
+    const list = {
         messageId: entry(message.id, `\`${message.id}\``),
         sentBy: entry(message.author.id, renderUser(message.author)),
         sentIn: entry(message.channel.id, renderChannel(message.channel)),
@@ -33,116 +38,115 @@
             message.reference ? message.reference.messageId : null,
             message.reference ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
         )
-    }
+    };
 
     if (config.filters.invite.enabled) {
-        if (!config.filters.invite.allowed.users.includes(message.author.id) ||
-            !config.filters.invite.allowed.channels.includes(message.channel.id) ||
-            !message.author.roles.cache.some(role => config.filters.invite.allowed.roles.includes(role.id))
-        ) {
+        if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
             if ((/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content))) {
-                createLogException(message.guild.id, message.channel.id, message.id)
+                createLogException(message.guild.id, message.channel.id, message.id);
                 message.delete();
-                let data = {
+                const data = {
                     meta: {
-                        type: 'messageDelete',
-                        displayName: 'Message Deleted (Automated, Contained Invite)',
-                        calculateType: 'autoModeratorDeleted',
+                        type: "messageDelete",
+                        displayName: "Message Deleted (Automated, Contained Invite)",
+                        calculateType: "autoModeratorDeleted",
                         color: NucleusColors.red,
-                        emoji: 'MESSAGE.DELETE',
+                        emoji: "MESSAGE.DELETE",
                         timestamp: new Date().getTime()
                     },
                     separate: {
-                        start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                        start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                     },
                     list: list,
                     hidden: {
                         guild: message.channel.guild.id
                     }
-                }
+                };
                 return log(data);
             }
         }
     }
 
     if (fileNames.files.length > 0) {
-        for (let element of fileNames.files) {
+        for (const element of fileNames.files) {
             if(!message) return;
-            let url = element.url ? element.url : element.local
+            const url = element.url ? element.url : element.local;
             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 (config.filters.images.NSFW && !(
+                        message.channel.type === "GUILD_PUBLIC_THREAD" ? false : message.channel.nsfw
+                    )) {
                         if (await NSFWCheck(url)) {
-                            createLogException(message.guild.id, message.channel.id, message.id)
-                            await message.delete()
-                            let data = {
+                            createLogException(message.guild.id, message.channel.id, message.id);
+                            await message.delete();
+                            const data = {
                                 meta: {
-                                    type: 'messageDelete',
-                                    displayName: 'Message Deleted',
-                                    calculateType: 'autoModeratorDeleted',
+                                    type: "messageDelete",
+                                    displayName: "Message Deleted",
+                                    calculateType: "autoModeratorDeleted",
                                     color: NucleusColors.red,
-                                    emoji: 'MESSAGE.DELETE',
+                                    emoji: "MESSAGE.DELETE",
                                     timestamp: new Date().getTime()
                                 },
                                 separate: {
-                                    start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                    start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                                 },
                                 list: list,
                                 hidden: {
                                     guild: message.channel.guild.id
                                 }
-                            }
+                            };
                             return log(data);
                         }
                     }
                     if (config.filters.wordFilter.enabled) {
-                        let text = await TestImage(url)
-                        let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+                        const text = await TestImage(url);
+                        const 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 = {
+                            createLogException(message.guild.id, message.channel.id, message.id);
+                            await message.delete();
+                            const data = {
                                 meta: {
-                                    type: 'messageDelete',
-                                    displayName: 'Message Deleted',
-                                    calculateType: 'autoModeratorDeleted',
+                                    type: "messageDelete",
+                                    displayName: "Message Deleted",
+                                    calculateType: "autoModeratorDeleted",
                                     color: NucleusColors.red,
-                                    emoji: 'MESSAGE.DELETE',
+                                    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*'),
+                                    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);
                         }
                     }
                     if (config.filters.images.size) {
                         if(url.match(/\.+(webp|png|jpg)$/gi)) {
                             if(!await SizeCheck(element)) {
-                                createLogException(message.guild.id, message.channel.id, message.id)
-                                await message.delete()
-                                let data = {
+                                createLogException(message.guild.id, message.channel.id, message.id);
+                                await message.delete();
+                                const data = {
                                     meta: {
-                                        type: 'messageDelete',
-                                        displayName: 'Message Deleted',
-                                        calculateType: 'autoModeratorDeleted',
+                                        type: "messageDelete",
+                                        displayName: "Message Deleted",
+                                        calculateType: "autoModeratorDeleted",
                                         color: NucleusColors.red,
-                                        emoji: 'MESSAGE.DELETE',
+                                        emoji: "MESSAGE.DELETE",
                                         timestamp: new Date().getTime()
                                     },
                                     separate: {
-                                        start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                        start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                                     },
                                     list: list,
                                     hidden: {
                                         guild: message.channel.guild.id
                                     }
-                                }
+                                };
                                 return log(data);
                             }
                         }
@@ -150,150 +154,150 @@
                 }
                 if (config.filters.malware) {
                     if (!MalwareCheck(url)) {
-                        createLogException(message.guild.id, message.channel.id, message.id)
-                        await message.delete()
-                        let data = {
+                        createLogException(message.guild.id, message.channel.id, message.id);
+                        await message.delete();
+                        const data = {
                             meta: {
-                                type: 'messageDelete',
-                                displayName: 'Message Deleted',
-                                calculateType: 'autoModeratorDeleted',
+                                type: "messageDelete",
+                                displayName: "Message Deleted",
+                                calculateType: "autoModeratorDeleted",
                                 color: NucleusColors.red,
-                                emoji: 'MESSAGE.DELETE',
+                                emoji: "MESSAGE.DELETE",
                                 timestamp: new Date().getTime()
                             },
                             separate: {
-                                start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                                start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
                             },
                             list: list,
                             hidden: {
                                 guild: message.channel.guild.id
                             }
-                        }
+                        };
                         return log(data);
                     }
                 }
             }
-        };
+        }
     }
     if(!message) return;
 
-    let linkDetectionTypes = await LinkCheck(message)
+    const linkDetectionTypes = await LinkCheck(message);
     if (linkDetectionTypes.length > 0) {
-        createLogException(message.guild.id, message.channel.id, message.id)
-        await message.delete()
-        let data = {
+        createLogException(message.guild.id, message.channel.id, message.id);
+        await message.delete();
+        const data = {
             meta: {
-                type: 'messageDelete',
-                displayName: `Message Deleted`,
-                calculateType: 'autoModeratorDeleted',
+                type: "messageDelete",
+                displayName: "Message Deleted",
+                calculateType: "autoModeratorDeleted",
                 color: NucleusColors.red,
-                emoji: 'MESSAGE.DELETE',
+                emoji: "MESSAGE.DELETE",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: filter + ` Link filtered as ${linkDetectionTypes[0].toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                start: filter + ` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
             },
             list: list,
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         return log(data);
     }
 
     if (config.filters.wordFilter.enabled) {
-        let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+        const check = TestString(content, 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 = {
+            createLogException(message.guild.id, message.channel.id, message.id);
+            await message.delete();
+            const data = {
                 meta: {
-                    type: 'messageDelete',
-                    displayName: 'Message Deleted',
-                    calculateType: 'autoModeratorDeleted',
+                    type: "messageDelete",
+                    displayName: "Message Deleted",
+                    calculateType: "autoModeratorDeleted",
                     color: NucleusColors.red,
-                    emoji: 'MESSAGE.DELETE',
+                    emoji: "MESSAGE.DELETE",
                     timestamp: new Date().getTime()
                 },
                 separate: {
-                    start: filter + ` Message contained filtered word\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+                    start: filter + " Message 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);
         }
     }
 
     if (config.filters.pings.everyone && message.mentions.everyone) {
-        let data = {
+        const data = {
             meta: {
-                type: 'everyonePing',
-                displayName: 'Everyone Pinged',
-                calculateType: 'messageMassPing',
+                type: "everyonePing",
+                displayName: "Everyone Pinged",
+                calculateType: "messageMassPing",
                 color: NucleusColors.yellow,
-                emoji: 'MESSAGE.PING.EVERYONE',
+                emoji: "MESSAGE.PING.EVERYONE",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                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) {
+        for(const roleId in 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 = {
+            if (!config.filters.pings.allowed.roles.includes(roleId)) {
+                createLogException(message.guild.id, message.channel.id, message.id);
+                await message.delete();
+                const data = {
                     meta: {
-                        type: 'rolePing',
-                        displayName: 'Role Pinged',
-                        calculateType: 'messageMassPing',
+                        type: "rolePing",
+                        displayName: "Role Pinged",
+                        calculateType: "messageMassPing",
                         color: NucleusColors.yellow,
-                        emoji: 'MESSAGE.PING.ROLE',
+                        emoji: "MESSAGE.PING.ROLE",
                         timestamp: new Date().getTime()
                     },
                     separate: {
-                        start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                        start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
                     },
                     list: list,
                     hidden: {
                         guild: message.channel.guild.id
                     }
-                }
+                };
                 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 = {
+        createLogException(message.guild.id, message.channel.id, message.id);
+        await message.delete();
+        const data = {
             meta: {
-                type: 'massPing',
-                displayName: `Mass Ping`,
-                calculateType: 'messageMassPing',
+                type: "massPing",
+                displayName: "Mass Ping",
+                calculateType: "messageMassPing",
                 color: NucleusColors.yellow,
-                emoji: 'MESSAGE.PING.MASS',
+                emoji: "MESSAGE.PING.MASS",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
             },
             list: list,
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         return log(data);
     }
 }
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index b139297..473fa52 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -1,34 +1,34 @@
-export const event = 'messageDelete'
+export const event = "messageDelete";
 
 export async function callback(client, message) {
     try {
         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();
+        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger;
+        const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
+        const audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
         if (audit) {
             if (audit.createdAt - 100 < new Date().getTime()) return;
         }
-        message.reference = message.reference || {}
-        let content = message.cleanContent
-        content.replace(`\``, `\\\``)
-        if (content.length > 256) content = content.substring(0, 253) + '...'
-        let attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []).length
-        let attachmentJump = ""
-        let config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
-        if (config) { attachmentJump = ` [[View attachments]](${config})` }
-        let data = {
+        message.reference = message.reference || {};
+        let content = message.cleanContent;
+        content.replace("`", "\\`");
+        if (content.length > 256) content = content.substring(0, 253) + "...";
+        const attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi) ?? []).length;
+        let attachmentJump = "";
+        const config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
+        if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+        const data = {
             meta: {
-                type: 'messageDelete',
-                displayName: 'Message Deleted',
-                calculateType: 'messageDelete',
+                type: "messageDelete",
+                displayName: "Message Deleted",
+                calculateType: "messageDelete",
                 color: NucleusColors.red,
-                emoji: 'MESSAGE.DELETE',
+                emoji: "MESSAGE.DELETE",
                 timestamp: new Date().getTime()
             },
             separate: {
-                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+                start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
             },
             list: {
                 messageId: entry(message.id, `\`${message.id}\``),
@@ -45,7 +45,7 @@
             hidden: {
                 guild: message.channel.guild.id
             }
-        }
+        };
         log(data);
-    } catch(e) { console.log(e) }
+    } catch(e) { console.log(e); }
 }
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 9e0e521..148cdb7 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -1,85 +1,83 @@
-export const event = 'messageUpdate'
+export const event = "messageUpdate";
 
 export async function callback(client, oldMessage, newMessage) {
-    try {
-        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("`", "‘")
-        let oldContent = oldMessage.cleanContent.replaceAll("`", "‘")
-        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 (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
-                let data = {
-                    meta: {
-                        type: 'messageAnnounce',
-                        displayName: 'Message Published',
-                        calculateType: 'messageAnnounce',
-                        color: NucleusColors.yellow,
-                        emoji: 'MESSAGE.CREATE',
-                        timestamp: newMessage.editedTimestamp
-                    },
-                    separate: {
-                        end: `[[Jump to message]](${newMessage.url})`
-                    },
-                    list: {
-                        messageId: entry(newMessage.id, `\`${newMessage.id}\``),
-                        sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
-                        sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
-                        sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
-                        published: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
-                        mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
-                        attachments: entry(
-                            renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
-                            renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
-                        )
-                    },
-                    hidden: {
-                        guild: newMessage.channel.guild.id
-                    }
+    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("`", "‘");
+    let oldContent = oldMessage.cleanContent.replaceAll("`", "‘");
+    let attachmentJump = "";
+    const 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 (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
+            const data = {
+                meta: {
+                    type: "messageAnnounce",
+                    displayName: "Message Published",
+                    calculateType: "messageAnnounce",
+                    color: NucleusColors.yellow,
+                    emoji: "MESSAGE.CREATE",
+                    timestamp: newMessage.editedTimestamp
+                },
+                separate: {
+                    end: `[[Jump to message]](${newMessage.url})`
+                },
+                list: {
+                    messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+                    sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+                    sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+                    sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+                    published: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+                    mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+                    attachments: entry(
+                        renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+                        renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+                    )
+                },
+                hidden: {
+                    guild: newMessage.channel.guild.id
                 }
-                return log(data);
-            }
-        };
-        if (!newMessage.editedTimestamp) { return }
-        if (newContent.length > 256) newContent = newContent.substring(0, 253) + '...'
-        if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + '...'
-        let data = {
-            meta: {
-                type: 'messageUpdate',
-                displayName: 'Message Edited',
-                calculateType: 'messageUpdate',
-                color: NucleusColors.yellow,
-                emoji: 'MESSAGE.EDIT',
-                timestamp: newMessage.editedTimestamp
-            },
-            separate: {
-                start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : '**Before:** *Message had no content*\n') +
-                    (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : '**After:** *Message had no content*'),
-                end: `[[Jump to message]](${newMessage.url})`
-            },
-            list: {
-                messageId: entry(newMessage.id, `\`${newMessage.id}\``),
-                sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
-                sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
-                sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
-                edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
-                mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
-                attachments: entry(
-                    renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
-                    renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
-                ),
-                repliedTo: entry(
-                    newMessage.reference.messageId || null,
-                    newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
-                )
-            },
-            hidden: {
-                guild: newMessage.channel.guild.id
-            }
+            };
+            return log(data);
         }
-        log(data);
-    } catch {}
-}
+    }
+    if (!newMessage.editedTimestamp) { return; }
+    if (newContent.length > 256) newContent = newContent.substring(0, 253) + "...";
+    if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + "...";
+    const data = {
+        meta: {
+            type: "messageUpdate",
+            displayName: "Message Edited",
+            calculateType: "messageUpdate",
+            color: NucleusColors.yellow,
+            emoji: "MESSAGE.EDIT",
+            timestamp: newMessage.editedTimestamp
+        },
+        separate: {
+            start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : "**Before:** *Message had no content*\n") +
+                (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : "**After:** *Message had no content*"),
+            end: `[[Jump to message]](${newMessage.url})`
+        },
+        list: {
+            messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+            sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+            sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+            sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+            edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+            mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+            attachments: entry(
+                renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+                renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+            ),
+            repliedTo: entry(
+                newMessage.reference.messageId || null,
+                newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
+            )
+        },
+        hidden: {
+            guild: newMessage.channel.guild.id
+        }
+    };
+    log(data);
+}
\ No newline at end of file
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 2f159ac..a717242 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,31 +1,29 @@
-export const event = 'roleCreate'
+export const event = "roleCreate";
 
 export async function callback(client, role) {
-    try {
-        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 data = {
-            meta: {
-                type: 'roleCreate',
-                displayName: 'Role Created',
-                calculateType: 'guildRoleUpdate',
-                color: NucleusColors.green,
-                emoji: "GUILD.ROLES.CREATE",
-                timestamp: role.createdTimestamp
-            },
-            list: {
-                roleId: entry(role.id, `\`${role.id}\``),
-                role: entry(role.name, renderRole(role)),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
-            },
-            hidden: {
-                guild: role.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger;
+    if (role.managed) return;
+    const auditLog = await getAuditLog(role.guild, "ROLE_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "roleCreate",
+            displayName: "Role Created",
+            calculateType: "guildRoleUpdate",
+            color: NucleusColors.green,
+            emoji: "GUILD.ROLES.CREATE",
+            timestamp: role.createdTimestamp
+        },
+        list: {
+            roleId: entry(role.id, `\`${role.id}\``),
+            role: entry(role.name, renderRole(role)),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
+        },
+        hidden: {
+            guild: role.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 3b43a55..ad74584 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -1,38 +1,36 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'roleDelete'
+export const event = "roleDelete";
 
 export async function callback(client, role) {
-    try {
-        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 data = {
-            meta: {
-                type: 'roleDelete',
-                displayName: 'Role Deleted',
-                calculateType: 'guildRoleUpdate',
-                color: NucleusColors.red,
-                emoji: "GUILD.ROLES.DELETE",
-                timestamp: audit.createdTimestamp,
-            },
-            list: {
-                roleId: entry(role.id, `\`${role.id}\``),
-                role: entry(role.name, role.name),
-                color: entry(role.hexColor, `\`${role.hexColor}\``),
-                showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
-                mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
-                members: entry(role.members.size, `${role.members.size}`),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
-                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
-            },
-            hidden: {
-                guild: role.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger;
+    if (role.managed) return;
+    const auditLog = await getAuditLog(role.guild, "ROLE_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "roleDelete",
+            displayName: "Role Deleted",
+            calculateType: "guildRoleUpdate",
+            color: NucleusColors.red,
+            emoji: "GUILD.ROLES.DELETE",
+            timestamp: audit.createdTimestamp
+        },
+        list: {
+            roleId: entry(role.id, `\`${role.id}\``),
+            role: entry(role.name, role.name),
+            color: entry(role.hexColor, `\`${role.hexColor}\``),
+            showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+            mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+            members: entry(role.members.size, `${role.members.size}`),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
+            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+        },
+        hidden: {
+            guild: role.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 7c03c97..c51a9b3 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -1,49 +1,47 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-export const event = 'roleUpdate';
+export const event = "roleUpdate";
 
 export async function callback(client, or, nr) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
 
-        let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
-        let audit = auditLog.entries.first();
-        if (audit.executor.id === client.user.id) return;
+    const auditLog = await getAuditLog(nr.guild, "ROLE_UPDATE");
+    const audit = auditLog.entries.first();
+    if (audit.executor.id === client.user.id) return;
 
-        let changes = {
-            roleId: entry(nr.id, `\`${nr.id}\``),
-            role: entry(nr.id, renderRole(nr)),
-            edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user)),
+    const changes = {
+        roleId: entry(nr.id, `\`${nr.id}\``),
+        role: entry(nr.id, renderRole(nr)),
+        edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+        editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user))
+    };
+    const mentionable = ["", ""];
+    const hoist = ["", ""];
+    mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+    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 (Object.keys(changes).length === 4) return;
+
+    const data = {
+        meta:{
+            type: "roleUpdate",
+            displayName: "Role Edited",
+            calculateType: "guildRoleUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.ROLES.EDIT",
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: nr.guild.id
         }
-        let mentionable = ["", ""]
-        let hoist = ["", ""]
-        mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
-        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 (Object.keys(changes).length === 4) return
-
-        let data = {
-            meta:{
-                type: 'roleUpdate',
-                displayName: 'Role Edited',
-                calculateType: 'guildRoleUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.ROLES.EDIT",
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: nr.guild.id
-            }
-        } // TODO: show perms changed (webpage)
-        log(data);
-    } catch {}
+    }; // TODO: show perms changed (webpage)
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 669de32..43f2e9c 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,30 +1,28 @@
-export const event = 'stickerCreate'
+export const event = "stickerCreate";
 
 export async function callback(client, emoji) {
-    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 data = {
-            meta: {
-                type: 'stickerCreate',
-                displayName: 'Sticker Created',
-                calculateType: 'stickerUpdate',
-                color: NucleusColors.green,
-                emoji: "GUILD.EMOJI.CREATE",
-                timestamp: emoji.createdTimestamp
-            },
-            list: {
-                stickerId: entry(emoji.id, `\`${emoji.id}\``),
-                emoji: entry(emoji.name, `\`:${emoji.name}:\``),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "STICKER_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "stickerCreate",
+            displayName: "Sticker Created",
+            calculateType: "stickerUpdate",
+            color: NucleusColors.green,
+            emoji: "GUILD.EMOJI.CREATE",
+            timestamp: emoji.createdTimestamp
+        },
+        list: {
+            stickerId: entry(emoji.id, `\`${emoji.id}\``),
+            emoji: entry(emoji.name, `\`:${emoji.name}:\``),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 0431bda..297e6b0 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,31 +1,29 @@
-export const event = 'stickerDelete'
+export const event = "stickerDelete";
 
 export async function callback(client, emoji) {
-    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 data = {
-            meta: {
-                type: 'stickerDelete',
-                displayName: 'Sticker Deleted',
-                calculateType: 'stickerUpdate',
-                color: NucleusColors.red,
-                emoji: "GUILD.EMOJI.DELETE",
-                timestamp: audit.createdTimestamp,
-            },
-            list: {
-                stickerId:entry(emoji.id, `\`${emoji.id}\``),
-                sticker: entry(emoji.name, `\`${emoji.name}\``),
-                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
-                deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
-            },
-            hidden: {
-                guild: emoji.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+    const auditLog = await getAuditLog(emoji.guild, "STICKER_DELETE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "stickerDelete",
+            displayName: "Sticker Deleted",
+            calculateType: "stickerUpdate",
+            color: NucleusColors.red,
+            emoji: "GUILD.EMOJI.DELETE",
+            timestamp: audit.createdTimestamp
+        },
+        list: {
+            stickerId:entry(emoji.id, `\`${emoji.id}\``),
+            sticker: entry(emoji.name, `\`${emoji.name}\``),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+            deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
+        },
+        hidden: {
+            guild: emoji.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 363e072..1bb0fe6 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,34 +1,32 @@
-export const event = 'stickerUpdate';
+export const event = "stickerUpdate";
 
 export async function callback(client, oe, ne) {
-    try {
-        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+    const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
 
-        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 (oe.name === ne.name) return;
+    const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
+    const audit = auditLog.entries.first();
+    if (audit.executor.id === client.user.id) return;
 
-        let changes = {
-            stickerId:entry(ne.id, `\`${ne.id}\``),
-            edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
-            editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
-            name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+    const changes = {
+        stickerId:entry(ne.id, `\`${ne.id}\``),
+        edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+        editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+        name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
+    };
+    const data = {
+        meta:{
+            type: "stickerUpdate",
+            displayName: "Sticker Edited",
+            calculateType: "stickerUpdate",
+            color: NucleusColors.yellow,
+            emoji: "GUILD.EMOJI.EDIT",
+            timestamp: audit.createdTimestamp
+        },
+        list: changes,
+        hidden: {
+            guild: ne.guild.id
         }
-        let data = {
-            meta:{
-                type: 'stickerUpdate',
-                displayName: 'Sticker Edited',
-                calculateType: 'stickerUpdate',
-                color: NucleusColors.yellow,
-                emoji: "GUILD.EMOJI.EDIT",
-                timestamp: audit.createdTimestamp
-            },
-            list: changes,
-            hidden: {
-                guild: ne.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
\ No newline at end of file
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index ef7246d..d6b9e93 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -1,34 +1,32 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadCreate'
+import humanizeDuration from "humanize-duration";
+export const event = "threadCreate";
 
 export async function callback(client, thread) {
-    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 data = {
-            meta: {
-                type: 'channelCreate',
-                displayName: 'Thread Created',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.green,
-                emoji: "CHANNEL.TEXT.CREATE",
-                timestamp: thread.createdTimestamp
-            },
-            list: {
-                threadId:entry(thread.id, `\`${thread.id}\``),
-                name: entry(thread.name, renderChannel(thread)),
-                parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
-                category: entry(thread.parent.parent ? thread.parent.parent.name : 'None', thread.parent.parent ? renderChannel(thread.parent.parent) : 'None'),
-                autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
-                createdBy: entry(audit.executor.id, renderUser(audit.executor)),
-                created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
-            },
-            hidden: {
-                guild: thread.guild.id
-            }
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+    const auditLog = await getAuditLog(thread.guild, "THREAD_CREATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const data = {
+        meta: {
+            type: "channelCreate",
+            displayName: "Thread Created",
+            calculateType: "channelUpdate",
+            color: NucleusColors.green,
+            emoji: "CHANNEL.TEXT.CREATE",
+            timestamp: thread.createdTimestamp
+        },
+        list: {
+            threadId:entry(thread.id, `\`${thread.id}\``),
+            name: entry(thread.name, renderChannel(thread)),
+            parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
+            category: entry(thread.parent.parent ? thread.parent.parent.name : "None", thread.parent.parent ? renderChannel(thread.parent.parent) : "None"),
+            autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
+            createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+            created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
+        },
+        hidden: {
+            guild: thread.guild.id
         }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 9574826..f3a59e7 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -1,17 +1,16 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadDelete'
+import humanizeDuration from "humanize-duration";
+export const event = "threadDelete";
 
 export async function callback(client, thread) {
-    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();
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+    const auditLog = await getAuditLog(thread.guild, "THREAD_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
     if (audit.executor.id === client.user.id) return;
-    let data = {
+    const data = {
         meta: {
-            type: 'channelDelete',
-            displayName: 'Thread Deleted',
-            calculateType: 'channelUpdate',
+            type: "channelDelete",
+            displayName: "Thread Deleted",
+            calculateType: "channelUpdate",
             color: NucleusColors.red,
             emoji: "CHANNEL.TEXT.DELETE",
             timestamp: new Date().getTime()
@@ -20,7 +19,7 @@
             threadId:entry(thread.id, `\`${thread.id}\``),
             name: entry(thread.name, thread.name),
             parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
-            category: entry(thread.parent.parent ? thread.parent.parent.name : 'None', thread.parent.parent ? renderChannel(thread.parent.parent) : 'None'),
+            category: entry(thread.parent.parent ? thread.parent.parent.name : "None", thread.parent.parent ? renderChannel(thread.parent.parent) : "None"),
             autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
             membersInThread: entry(thread.memberCount, thread.memberCount),
             deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
@@ -30,7 +29,6 @@
         hidden: {
             guild: thread.guild.id
         }
-    }
+    };
     log(data);
-    } catch {}
 }
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 8550ffe..89a721c 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -1,43 +1,41 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadUpdate'
+import humanizeDuration from "humanize-duration";
+export const event = "threadUpdate";
 
 export async function callback(client, before, after) {
-    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 list = {
-            threadId:entry(after.id, `\`${after.id}\``),
-            thread: entry(after.name, renderChannel(after)),
-            parentChannel: entry(after.parentId, renderChannel(after.parent)),
+    const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger;
+    const auditLog = await getAuditLog(after.guild, "THREAD_UPDATE");
+    const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+    if (audit.executor.id === client.user.id) return;
+    const 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) {
+        list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+    }
+    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) {
+        list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
+    }
+    if (!(Object.keys(list).length - 3)) return;
+    list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+    list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+    const data = {
+        meta: {
+            type: "channelUpdate",
+            displayName: "Thread Edited",
+            calculateType: "channelUpdate",
+            color: NucleusColors.yellow,
+            emoji: "CHANNEL.TEXT.EDIT",
+            timestamp: new Date().getTime()
+        },
+        list: list,
+        hidden: {
+            guild: after.guild.id
         }
-        if (before.name !== after.name) {
-            list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
-        }
-        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) {
-            list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
-        }
-        if (!(Object.keys(list).length - 3)) return;
-        list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
-        list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
-        let data = {
-            meta: {
-                type: 'channelUpdate',
-                displayName: 'Thread Edited',
-                calculateType: 'channelUpdate',
-                color: NucleusColors.yellow,
-                emoji: "CHANNEL.TEXT.EDIT",
-                timestamp: new Date().getTime()
-            },
-            list: list,
-            hidden: {
-                guild: after.guild.id
-            }
-        }
-        log(data);
-    } catch {}
+    };
+    log(data);
 }
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 28768b2..a11fa63 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -1,35 +1,38 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'webhookUpdate'
+import type Discord from "discord.js";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { HaikuClient } from "jshaiku";
+export const event = "webhookUpdate";
 
-export async function callback(client, channel) {
+export async function callback(client: HaikuClient, channel: Discord.GuildChannel) {
     try {
-        const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
-        let auditLogCreate = getAuditLog(channel.guild, 'WEBHOOK_CREATE');
-        let auditLogUpdate = getAuditLog(channel.guild, 'WEBHOOK_UPDATE');
-        let auditLogDelete = getAuditLog(channel.guild, 'WEBHOOK_DELETE');
+        const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+        let auditLogCreate = getAuditLog(channel.guild, "WEBHOOK_CREATE");
+        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();
+        const auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
+        const auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
+        const auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
         if (!auditCreate && !auditUpdate && !auditDelete) return;
         let audit = auditCreate;
         let action = "Create";
-        let list = {} as any;
+        let list = {} as {created: { value: string, displayValue: string }, updated: { value: string, displayValue: string }, deleted: { value: string, displayValue: string }};
         if (auditUpdate && auditUpdate.createdTimestamp > audit.createdTimestamp) {
-            let {before, after} = auditUpdate.changes.reduce(
+            const {before, after} = auditUpdate.changes.reduce(
                 (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
                 {before: {}, after: {}}
             );
-            if (before.name !== after.name) list['name'] = entry([before.name, after.name], `${before.name} -> ${after.name}`)
-            if (before.channel_id !== after.channel_id) list['channel'] = entry([before.channel_id, after.channel_id], renderChannel(await client.channels.fetch(before.channel_id)) + ` -> ` + renderChannel(await client.channels.fetch(after.channel_id)))
+            if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+            if (before.channel_id !== after.channel_id) list["channel"] = entry([before.channel_id, after.channel_id], renderChannel(await client.channels.fetch(before.channel_id)) + " -> " + renderChannel(await client.channels.fetch(after.channel_id)));
             if (!(Object.keys(list)).length) return;
             list.created = entry(auditUpdate.target.createdTimestamp, renderDelta(auditUpdate.target.createdTimestamp));
             list.edited = entry(after.editedTimestamp, renderDelta(new Date().getTime()));
             list.editedBy = entry(auditUpdate.executor.id, renderUser(auditUpdate.executor));
             audit = auditUpdate;
-            action = "Update"
+            action = "Update";
         } else if (auditDelete && auditDelete.createdTimestamp > audit.createdTimestamp) {
-            let {before, after} = auditDelete.changes.reduce(
+            const {before} = auditDelete.changes.reduce(
                 (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
                 {before: {}, after: {}}
             );
@@ -38,12 +41,12 @@
                 channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
                 created: entry(auditDelete.target.createdTimestamp, renderDelta(auditDelete.target.createdTimestamp)),
                 deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-                deletedBy: entry(auditDelete.executor.id, renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user)),
-            }
+                deletedBy: entry(auditDelete.executor.id, renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user))
+            };
             audit = auditDelete;
-            action = "Delete"
+            action = "Delete";
         } else {
-            let {before, after} = auditDelete.changes.reduce(
+            const {before} = auditDelete.changes.reduce(
                 (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
                 {before: {}, after: {}}
             );
@@ -51,19 +54,19 @@
                 name: entry(before.name, `${before.name}`),
                 channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
                 createdBy: entry(auditCreate.executor.id, renderUser((await channel.guild.members.fetch(auditCreate.executor.id)).user)),
-                created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-            }
+                created: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+            };
         }
-        let cols = {
+        const cols = {
             "Create": "green",
             "Update": "yellow",
-            "Delete": "red",
-        }
-        let data = {
+            "Delete": "red"
+        };
+        const data = {
             meta: {
-                type: 'webhook' + action,
+                type: "webhook" + action,
                 displayName: `Webhook ${action}d`,
-                calculateType: 'webhookUpdate',
+                calculateType: "webhookUpdate",
                 color: NucleusColors[cols[action]],
                 emoji: "WEBHOOK." + action.toUpperCase(),
                 timestamp: new Date().getTime()
@@ -72,7 +75,7 @@
             hidden: {
                 guild: channel.guild.id
             }
-        }
+        };
         log(data);
-    } catch(e) { console.log(e) }
+    } catch(e) { console.log(e); }
 }
diff --git a/src/index.ts b/src/index.ts
index 5f5987e..22436e2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,10 +1,10 @@
 
-import { Logger } from './utils/log.js';
-import runServer from './api/index.js';
-import Memory from './utils/memory.js';
-import { Guilds, History, ModNotes, Premium } from './utils/database.js';
-import client from './utils/client.js';
-import EventScheduler from './utils/eventScheduler.js';
+import { Logger } from "./utils/log.js";
+import runServer from "./api/index.js";
+import Memory from "./utils/memory.js";
+import { Guilds, History, ModNotes, Premium } from "./utils/database.js";
+import client from "./utils/client.js";
+import EventScheduler from "./utils/eventScheduler.js";
 
 await client.registerCommandsIn("./commands");
 await client.registerEventsIn("./events");
@@ -15,17 +15,17 @@
     console.error(err);
 });
 
-client.logger = new Logger()
-client.verify = {}
-client.roleMenu = {}
-client.memory = new Memory()
-client.noLog = []
+client.logger = new Logger();
+client.verify = {};
+client.roleMenu = {};
+client.memory = new Memory();
+client.noLog = [];
 client.database = {
     guilds: await new Guilds().setup(),
     history: await new History().setup(),
     notes: await new ModNotes().setup(),
     premium: await new Premium().setup(),
     eventScheduler: await new EventScheduler().start()
-}
+};
 
 await client.login();
\ No newline at end of file
diff --git a/src/premium/attachmentLogs.ts b/src/premium/attachmentLogs.ts
index ed9a4ab..5a771bc 100644
--- a/src/premium/attachmentLogs.ts
+++ b/src/premium/attachmentLogs.ts
@@ -1,42 +1,44 @@
-import client from '../utils/client.js';
-import keyValueList from '../utils/generateKeyValueList.js';
-import singleNotify from '../utils/singleNotify.js';
-import { saveAttachment } from '../reflex/scanners.js';
-import EmojiEmbed from '../utils/generateEmojiEmbed.js';
-import addPlural from '../utils/plurals.js';
+import client from "../utils/client.js";
+import keyValueList from "../utils/generateKeyValueList.js";
+import singleNotify from "../utils/singleNotify.js";
+import { saveAttachment } from "../reflex/scanners.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
+import addPlural from "../utils/plurals.js";
+import type { Message } from "discord.js";
 
 
-export default async function logAttachment(message): Promise<AttachmentLogSchema> {
+export default async function logAttachment(message: Message): Promise<AttachmentLogSchema> {
+    if (!message.guild) throw new Error("Tried to log an attachment in a non-guild message");
     const { renderUser, renderChannel, renderDelta } = client.logger;
-    let attachments = []
-    for (let attachment of message.attachments.values()) {
-        attachments.push({local: await saveAttachment(attachment.url), url: attachment.url})
+    const attachments = [];
+    for (const attachment of message.attachments.values()) {
+        attachments.push({local: await saveAttachment(attachment.url), url: attachment.url, height: attachment.height, width: attachment.width, size: attachment.size});
     }
-    let links = message.content.match(/https?:\/\/\S+/gi) || [];
-    for (let link of links) {
+    const links = message.content.match(/https?:\/\/\S+/gi) || [];
+    for (const link of links) {
         if (link.toLowerCase().match(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/gi)) {
-            attachments.push({local: await saveAttachment(link), url: link})
+            attachments.push({local: await saveAttachment(link), url: link, height: null, width: null});
         }
     }
-    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;
+        const channel = (await client.database.guilds.read(message.guild.id)).logging.attachments.channel;
         if (!channel) {
             singleNotify("noAttachmentLogChannel", message.guild.id, "No channel set for attachment logging", "Warning");
             return {files: attachments};
         }
-        let channelObj = await client.channels.fetch(channel);
+        const channelObj = await client.channels.fetch(channel);
         if (!channelObj) {
             singleNotify("attachmentLogChannelDeleted", message.guild.id, "Attachment history channel was deleted", "Warning");
             return {files: attachments};
         }
-        let m = await channelObj.send({embeds: [new EmojiEmbed()
+        const m = await channelObj.send({embeds: [new EmojiEmbed()
             .setTitle(`${addPlural(attachments.length, "Attachment")} Sent`)
             .setDescription(keyValueList({
                 "messageId": `\`${message.id}\``,
                 "sentBy": renderUser(message.author),
                 "sentIn": renderChannel(message.channel),
-                "sent": renderDelta(new Date(message.createdTimestamp)),
+                "sent": renderDelta(new Date(message.createdTimestamp))
             }) + `\n[[Jump to message]](${message.url})`)
             .setEmoji("ICONS.ATTACHMENT")
             .setStatus("Success")
@@ -44,7 +46,7 @@
         // await client.database.guilds.write(interaction.guild.id, {[`tags.${name}`]: value});
         client.database.guilds.write(
             message.guild.id,
-            {[`logging.attachments.saved.${message.channel.id}${message.id}`]: m.url},
+            {[`logging.attachments.saved.${message.channel.id}${message.id}`]: m.url}
         );
         return {files: attachments, jump: m.url};
     } else {
@@ -55,7 +57,9 @@
 export interface AttachmentLogSchema {
     files: {
         url: string,
-        local: string;
+        local: string,
+        height: number | null,
+        width: number | null
     }[],
     jump?: string;
 }
\ No newline at end of file
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index 55697b9..d5d7bb8 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -2,50 +2,50 @@
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 import { PasteClient, Publicity, ExpireDate } from "pastebin-api";
-import config from '../config/main.json' assert {type: 'json'};
+import config from "../config/main.json" assert {type: "json"};
 import client from "../utils/client.js";
 
-const pbClient = new PasteClient(config.pastebinApiKey)
+const pbClient = new PasteClient(config.pastebinApiKey);
 
 export default async function (interaction) {
-    const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
+    const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
 
-    let messages = []
+    let messages = [];
     let 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);
-        })
-        deleted = fetched.size
+        });
+        deleted = fetched.size;
         if (fetched) {
-            messages = messages.concat(fetched.map(m => m))
+            messages = messages.concat(fetched.map(m => m));
         }
     }
-    let out = ""
+    let out = "";
     messages.reverse().forEach(message => {
         if (!message.author.bot) {
-            let sentDate = new Date(message.createdTimestamp)
-            out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${sentDate.toUTCString()}]\n`
-            let lines = message.content.split("\n")
-            lines.forEach(line => {out += `> ${line}\n`})
-            out += `\n\n`
+            const sentDate = new Date(message.createdTimestamp);
+            out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${sentDate.toUTCString()}]\n`;
+            const lines = message.content.split("\n");
+            lines.forEach(line => {out += `> ${line}\n`;});
+            out += "\n\n";
         }
-    })
-    let member = interaction.channel.guild.members.cache.get(interaction.channel.topic.split(" ")[0])
+    });
+    const member = interaction.channel.guild.members.cache.get(interaction.channel.topic.split(" ")[0]);
     let m;
     if (out !== "") {
         const url = await pbClient.createPaste({
             code: out,
             expireDate: ExpireDate.Never,
             name: `Ticket Transcript for ${member.user.username}#${member.user.discriminator} (Created at ${new Date(interaction.channel.createdTimestamp).toDateString()})`,
-            publicity: Publicity.Unlisted,
-        })
-        let guildConfig = await client.database.guilds.read(interaction.guild.id);
+            publicity: Publicity.Unlisted
+        });
+        const guildConfig = await client.database.guilds.read(interaction.guild.id);
         m = await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Transcript")
-            .setDescription(`You can view the transcript using the link below. You can save the link for later` + (guildConfig.logging.logs.channel ?
+            .setDescription("You can view the transcript using the link below. You can save the link for later" + (guildConfig.logging.logs.channel ?
                 ` or find it in <#${guildConfig.logging.logs.channel}> once you press delete below. After this the channel will be deleted.`
                 : "."))
             .setStatus("Success")
@@ -64,7 +64,7 @@
     } else {
         m = await interaction.reply({embeds: [new EmojiEmbed()
             .setTitle("Transcript")
-            .setDescription(`The transcript was empty, so no changes were made. To delete this ticket, press the delete button below.`)
+            .setDescription("The transcript was empty, so no changes were made. To delete this ticket, press the delete button below.")
             .setStatus("Success")
             .setEmoji("CONTROL.DOWNLOAD")
         ], components: [new MessageActionRow().addComponents([
@@ -78,15 +78,15 @@
     let i;
     try {
         i = await m.awaitMessageComponent({ time: 300000 });
-        i.deferUpdate()
-    } catch (e) { }
-    let data = {
+        i.deferUpdate();
+    } catch { return; }
+    const data = {
         meta:{
-            type: 'ticketDeleted',
-            displayName: 'Ticket Deleted',
+            type: "ticketDeleted",
+            displayName: "Ticket Deleted",
             calculateType: "ticketUpdate",
             color: NucleusColors.red,
-            emoji: 'GUILD.TICKET.CLOSE',
+            emoji: "GUILD.TICKET.CLOSE",
             timestamp: new Date().getTime()
         },
         list: {
@@ -97,8 +97,8 @@
         hidden: {
             guild: interaction.guild.id
         }
-    }
+    };
     log(data);
-    await interaction.channel.delete()
-    return
+    await interaction.channel.delete();
+    return;
 }
\ No newline at end of file
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 517d7f4..640ec13 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -1,16 +1,15 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
-import { SelectMenuOption } from '@discordjs/builders';
+import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
+import { SelectMenuOption } from "@discordjs/builders";
 import Discord, { MessageActionRow, MessageButton } from "discord.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";
 
 class Embed {
     embed: Discord.MessageEmbed;
     title: string;
-    description: string = "";
-    pageId: number = 0;
+    description = "";
+    pageId = 0;
     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; }
@@ -20,7 +19,7 @@
 export default async (guild, interaction?) => {
     let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
     c = c ? c : guild.channels.cache.find(ch => ch.type === "GUILD_TEXT" && ch.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES") && ch.permissionsFor(guild.me).has("EMBED_LINKS"));
-    let pages = [
+    const pages = [
         new Embed()
             .setEmbed(new EmojiEmbed()
                 .setTitle("Welcome to Nucleus")
@@ -62,8 +61,8 @@
                     `**${getEmojiByName("PUNISH.BAN.RED")} Ban:** The user is removed from the server, and they are unable to rejoin.\n` +
                     `**${getEmojiByName("PUNISH.BAN.GREEN")} Unban:** The user is able to rejoin the server.`
                 )
-            .setEmoji("PUNISH.BAN.RED")
-            .setStatus("Danger")
+                .setEmoji("PUNISH.BAN.RED")
+                .setStatus("Danger")
             ).setTitle("Moderation").setDescription("Basic moderation commands").setPageId(2),
         new Embed()
             .setEmbed(new EmojiEmbed()
@@ -124,53 +123,53 @@
                 )
                 .setEmoji("NUCLEUS.COMMANDS.LOCK")
                 .setStatus("Danger")
-            ).setTitle("Premium").setDescription("Premium features").setPageId(7),
-    ]
+            ).setTitle("Premium").setDescription("Premium features").setPageId(7)
+    ];
     let m;
     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) => {
+    const f = async (component) => {
         return (component.member as Discord.GuildMember).permissions.has("MANAGE_GUILD");
-    }
+    };
 
     let selectPaneOpen = false;
 
     while (true) {
-        let selectPane = []
+        let selectPane = [];
 
         if (selectPaneOpen) {
-            let options = [];
+            const options = [];
             pages.forEach(embed => {
                 options.push(new SelectMenuOption({
                     label: embed.title,
                     value: embed.pageId.toString(),
-                    description: embed.description || "",
-                }))
-            })
+                    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([
+        const 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)
-        ])])
+        ])]);
         if (interaction) {
-            let em = new Discord.MessageEmbed(pages[page].embed)
+            const em = new Discord.MessageEmbed(pages[page].embed);
             em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
             await interaction.editReply({
                 embeds: [em],
                 components: components
             });
         } else {
-            let em = new Discord.MessageEmbed(pages[page].embed)
+            const em = new Discord.MessageEmbed(pages[page].embed);
             em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
             await m.edit({
                 embeds: [em],
@@ -178,11 +177,11 @@
                 fetchReply: true
             });
         }
-        let i
+        let i;
         try {
-            i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, time: 300000});
-        } catch(e) { break }
-        i.deferUpdate()
+            i = await m.awaitMessageComponent({filter: interaction ? () => { return true; } : f, time: 300000});
+        } catch(e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
@@ -196,9 +195,9 @@
             selectPaneOpen = false;
         } else {
             if (interaction) {
-                let em = new Discord.MessageEmbed(pages[page].embed)
+                const em = new Discord.MessageEmbed(pages[page].embed);
                 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
-                em.setFooter({text: "Message closed"})
+                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),
@@ -211,7 +210,7 @@
         }
     }
     if (interaction) {
-        let em = new Discord.MessageEmbed(pages[page].embed)
+        const em = new Discord.MessageEmbed(pages[page].embed);
         em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
         await interaction.editReply({
             embeds: [em],
@@ -222,7 +221,7 @@
             ])]
         });
     } else {
-        let em = new Discord.MessageEmbed(pages[page].embed)
+        const em = new Discord.MessageEmbed(pages[page].embed);
         em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
         await m.edit({
             embeds: [em],
@@ -233,4 +232,4 @@
             ])]
         });
     }
-}
+};
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index 3b80816..435ce4c 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -1,33 +1,36 @@
-import * as us from 'unscan'
-import fetch from 'node-fetch'
-import { writeFileSync } from 'fs'
-import generateFileName from '../utils/temp/generateFileName.js'
-import Tesseract from 'node-tesseract-ocr';
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import * as us from "unscan";
+import fetch from "node-fetch";
+import { writeFileSync } from "fs";
+import generateFileName from "../utils/temp/generateFileName.js";
+import Tesseract from "node-tesseract-ocr";
+import type Discord from "discord.js";
 
 interface NSFWSchema { nsfw: boolean }
 interface MalwareSchema { safe: boolean }
 
 export async function testNSFW(link: string): Promise<NSFWSchema> {
-    let p = await saveAttachment(link)
-    let result = await us.nsfw.file(p)
-    return result
+    const p = await saveAttachment(link);
+    const result = await us.nsfw.file(p);
+    return result;
 }
 
 export async function testMalware(link: string): Promise<MalwareSchema> {
-    let p = await saveAttachment(link)
-    let result = await us.malware.file(p)
-    return result
+    const p = await saveAttachment(link);
+    const result = await us.malware.file(p);
+    return result;
 }
 
-export async function saveAttachment(link): Promise<string> {
-    const image = (await (await fetch(link)).buffer()).toString('base64')
-    let fileName = generateFileName(link.split('/').pop().split('.').pop())
-    writeFileSync(fileName, image, 'base64')
-    return fileName
+export async function saveAttachment(link: string): Promise<string> {
+    const image = (await (await fetch(link)).buffer()).toString("base64");
+    const fileName = generateFileName((link.split("/").pop() as string).split(".").pop() as string);
+    writeFileSync(fileName, image, "base64");
+    return fileName;
 }
 
-export async function testLink(link: string): Promise<unknown> {
-    return await us.link.scan(link)
+export async function testLink(link: string): Promise<{safe: boolean, tags: string[]}> {
+    return await us.link.scan(link);
 }
 
 
@@ -49,71 +52,76 @@
     "SCAMS": "Sites which are designed to trick you into doing something.",
     "TORRENT": "Websites that download torrent files.",
     "HATE": "Websites that spread hate towards groups or individuals.",
-    "JUNK": "Websites that are designed to make you waste time.",
-}
+    "JUNK": "Websites that are designed to make you waste time."
+};
 export { linkTypes };
 
 
-export async function LinkCheck(message): Promise<string[]> {
-    let links = message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []
-    let detections = []
-    const promises = links.map(async element => {
+export async function LinkCheck(message: Discord.Message): Promise<string[]> {
+    const links = message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi) ?? [];
+    const detections: {tags: string[], safe: boolean}[] = [];
+    const promises: Promise<void>[] = links.map(async element => {
+        let returned;
         try {
-            if (element.match(/https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/)) return // Also matches discord.net, not enough of a bug
-            element = await testLink(element)
-        } catch {}
-        detections.push({tags: element.tags || [], safe: element.safe})
+            if (element.match(/https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/)) return; // Also matches discord.net, not enough of a bug
+            returned = await testLink(element);
+        } catch {
+            detections.push({tags: [], safe: true});
+            return;
+        }
+        if (returned) { detections.push({tags: returned.tags || [], safe: returned.safe}); }
+        else { detections.push({tags: [], safe: true}); }
     });
     await Promise.all(promises);
-    let detectionsTypes = detections.map(element => {
-        let type = Object.keys(linkTypes).find(type => element.tags.includes(type))
-        if (type) return type
+    const detectionsTypes = detections.map(element => {
+        const type = Object.keys(linkTypes).find(type => element.tags.includes(type));
+        if (type) return type;
         // if (!element.safe) return "UNSAFE"
-        return undefined
-    }).filter(element => element !== undefined)
-    return detectionsTypes
+        return undefined;
+    }).filter(element => element !== undefined);
+    return detectionsTypes as string[];
 }
 
-export async function NSFWCheck(element): Promise<boolean> {
+export async function NSFWCheck(element: string): Promise<boolean> {
     try {
-        let test = (await testNSFW(element))
-        return test.nsfw
+        const test = (await testNSFW(element));
+        return test.nsfw;
     } catch {
-        return false
+        return false;
     }
 }
 
-export async function SizeCheck(element): Promise<boolean> {
-    if (element.height === undefined || element.width === undefined) return true
-    if (element.height < 20 || element.width < 20) return false
-    return true
+export async function SizeCheck(element: {height: number | null, width: number | null}): Promise<boolean> {
+    if (element.height === null || element.width === null) return true;
+    if (element.height < 20 || element.width < 20) return false;
+    return true;
 }
 
-export async function MalwareCheck(element): Promise<boolean> {
+export async function MalwareCheck(element: string): Promise<boolean> {
     try {
-        return (await testMalware(element)).safe
+        return (await testMalware(element)).safe;
     } catch {
-        return true
+        return true;
     }
 }
 
-export function TestString(string, soft, strict): object | null {
-    for(let word of strict || []) {
+export function TestString(string: string, soft: string[], strict: string[]): object | null {
+    for(const word of strict || []) {
         if (string.toLowerCase().includes(word)) {
-            return {word: word, type: "strict"}
+            return {word: word, type: "strict"};
         }
     }
-    for(let word of soft) {
-        for(let word2 of string.match(/[a-z]+/gi) || []) {
+    for(const word of soft) {
+        for(const word2 of string.match(/[a-z]+/gi) || []) {
             if (word2 === word) {
-                return {word: word, type: "strict"}
+                return {word: word, type: "strict"};
             }
         }
     }
-    return null
+    return null;
 }
 
-export async function TestImage(url): Promise<string | null> {
-    let text = await Tesseract.recognize(url, {lang: "eng", oem: 1, psm: 3})
+export async function TestImage(url: string): Promise<string | null> {
+    const text = await Tesseract.recognize(url, {lang: "eng", oem: 1, psm: 3});
     return text;
 }
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index b306ecc..7301a60 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -1,38 +1,38 @@
-import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
-import singleNotify from '../utils/singleNotify.js';
-import client from '../utils/client.js';
+import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
+import singleNotify from "../utils/singleNotify.js";
+import client from "../utils/client.js";
 
 interface PropSchema { enabled: boolean, name: string }
 
 export async function callback(_, member) {
-    let guild = await client.guilds.fetch(member.guild.id)
-    let config = await client.database.guilds.read(guild.id);
+    const guild = await client.guilds.fetch(member.guild.id);
+    const config = await client.database.guilds.read(guild.id);
     Object.entries(config.getKey("stats")).forEach(async ([channel, props]) => {
         if ((props as PropSchema).enabled) {
-            let string = (props as PropSchema).name
-            if (!string) return
-            string = await convertCurlyBracketString(string, member.id, member.displayName, guild.name, guild.members)
+            let string = (props as PropSchema).name;
+            if (!string) return;
+            string = await convertCurlyBracketString(string, member.id, member.displayName, guild.name, guild.members);
             let fetchedChannel;
             try {
-                fetchedChannel = await guild.channels.fetch(channel)
-            } catch (e) { fetchedChannel = null }
+                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}`)
+                const 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 use `/settings stats` if you wish to add the channel again.\n" +
                     `The channels name was: ${deleted.name}`,
                     "Critical"
-                )
+                );
             }
             try {
-                await fetchedChannel.setName(string.slice(0, 100))
+                await fetchedChannel.setName(string.slice(0, 100));
             } catch (e) {
-                console.error(e)
+                console.error(e);
             }
         }
     });
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index bc7aa4f..d9fab66 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
+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 +11,12 @@
 }
 
 export default async function(interaction) {
-    let verify = client.verify
+    const verify = client.verify;
     await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
-    let config = await client.database.guilds.read(interaction.guild.id);
+    const config = await client.database.guilds.read(interaction.guild.id);
     if ((!config.verify.enabled ) || (!config.verify.role)) return interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`Verify is not enabled on this server`)
+        .setDescription("Verify is not enabled on this server")
         .setFooter({text: interaction.member.permissions.has("MANAGE_GUILD") ? "You can enable it by running /settings verify" : ""})
         .setStatus("Danger")
         .setEmoji("CONTROL.BLOCKCROSS")
@@ -31,16 +31,16 @@
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`Checking our servers are up` + step(0))
+        .setDescription("Checking our servers are up" + step(0))
         .setStatus("Warning")
         .setEmoji("NUCLEUS.LOADING")
     ]});
     try {
-        let status = await fetch(client.config.baseUrl).then(res => res.status);
+        const status = await fetch(client.config.baseUrl).then(res => res.status);
         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))
+                .setDescription("Our servers appear to be down, please try again later" + step(0))
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
             ]});
@@ -48,7 +48,7 @@
     } catch {
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify")
-            .setDescription(`Our servers appear to be down, please try again later` + step(0))
+            .setDescription("Our servers appear to be down, please try again later" + step(0))
             .setStatus("Danger")
             .setEmoji("CONTROL.BLOCKCROSS")
         ], components: [new Discord.MessageActionRow().addComponents([
@@ -65,14 +65,14 @@
     if (config.filters.images.NSFW) {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify")
-            .setDescription(`Checking your avatar is safe for work` + step(1))
+            .setDescription("Checking your avatar is safe for work" + step(1))
             .setStatus("Warning")
             .setEmoji("NUCLEUS.LOADING")
         ]});
         if (await NSFWCheck((interaction.member as GuildMember).user.avatarURL({format: "png"}))) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify")
-                .setDescription(`Your avatar was detected as NSFW, which we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake` + step(1))
+                .setDescription("Your avatar was detected as NSFW, which we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake" + step(1))
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
             ]});
@@ -81,14 +81,14 @@
     if (config.filters.wordFilter) {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify")
-            .setDescription(`Checking your name is allowed` + step(2))
+            .setDescription("Checking your name is allowed" + step(2))
             .setStatus("Warning")
             .setEmoji("NUCLEUS.LOADING")
         ]});
         if (TestString((interaction.member as Discord.GuildMember).displayName, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict) !== null) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify")
-                .setDescription(`Your name contained a word we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake` + step(2))
+                .setDescription("Your name contained a word we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake" + step(2))
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
             ]});
@@ -96,23 +96,23 @@
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`One moment...` + step(3))
+        .setDescription("One moment..." + step(3))
         .setStatus("Warning")
         .setEmoji("NUCLEUS.LOADING")
     ]});
-    let code = ""
-    let length = 5
-    let itt = 0
+    let code = "";
+    let length = 5;
+    let itt = 0;
     const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
     while (true) {
-        itt += 1
-        code = ""
+        itt += 1;
+        code = "";
         for (let i = 0; i < length; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); }
         if (code in verify) continue;
         if (itt > 1000) {
-            itt = 0
-            length += 1
-            continue
+            itt = 0;
+            length += 1;
+            continue;
         }
         break;
     }
@@ -125,10 +125,10 @@
         gName: interaction.guild.name,
         gIcon: interaction.guild.iconURL({format: "png"}),
         interaction: interaction
-    }
+    };
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`Looking good!\nClick the button below to get verified` + step(4))
+        .setDescription("Looking good!\nClick the button below to get verified" + step(4))
         .setStatus("Success")
         .setEmoji("MEMBER.JOIN")
     ], components: [new Discord.MessageActionRow().addComponents([new Discord.MessageButton()
diff --git a/src/reflex/welcome.ts b/src/reflex/welcome.ts
index 9be71d5..b4bc374 100644
--- a/src/reflex/welcome.ts
+++ b/src/reflex/welcome.ts
@@ -1,39 +1,37 @@
-import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
-import client from '../utils/client.js';
-import EmojiEmbed from '../utils/generateEmojiEmbed.js';
+import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
+import client from "../utils/client.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 
 export async function callback(_, member) {
-    if (member.bot) return
-    let config = await client.database.guilds.read(member.guild.id);
-    if (!config.welcome.enabled) return
+    if (member.bot) return;
+    const config = await client.database.guilds.read(member.guild.id);
+    if (!config.welcome.enabled) return;
 
     if (config.welcome.channel) {
-        let string = config.welcome.message
+        let string = config.welcome.message;
         if (string) {
-            string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
-            if (config.welcome.channel === 'dm') {
-                try {
-                    await member.send({
-                        embeds: [new EmojiEmbed()
-                            .setDescription(string)
-                            .setStatus('Success')
-                        ]
-                    })
-                } catch {}
+            string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members);
+            if (config.welcome.channel === "dm") {
+                await member.send({
+                    embeds: [new EmojiEmbed()
+                        .setDescription(string)
+                        .setStatus("Success")
+                    ]
+                });
             } else {
-                let channel = await member.guild.channels.fetch(config.welcome.channel)
-                if (channel.guild.id !== member.guild.id) return
-                if (!channel) return
+                const channel = await member.guild.channels.fetch(config.welcome.channel);
+                if (channel.guild.id !== member.guild.id) return;
+                if (!channel) return;
                 try {
                     await channel.send({
                         embeds: [new EmojiEmbed()
                             .setDescription(string)
-                            .setStatus('Success')
+                            .setStatus("Success")
                         ],
-                        content: (config.welcome.ping ? `<@${config.welcome.ping}>` : '') + `<@${member.id}>`
-                    })
+                        content: (config.welcome.ping ? `<@${config.welcome.ping}>` : "") + `<@${member.id}>`
+                    });
                 } catch (err) {
-                    console.error(err) // SEN
+                    console.error(err); // TODO: SEN
                 }
             }
         }
diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts
index 8badc58..9bdef3b 100644
--- a/src/utils/calculate.ts
+++ b/src/utils/calculate.ts
@@ -19,7 +19,7 @@
     "autoModeratorDeleted",
     "nucleusSettingsUpdated",
     "ticketUpdate"
-]
+];
 
 const tickets = [
     "support",
@@ -28,7 +28,7 @@
     "issue",
     "suggestion",
     "other"
-]
+];
 
 const toHexInteger = (permissions, array?) => {
     if (!array) {
@@ -36,29 +36,29 @@
     }
     let int = 0n;
 
-    for(let perm of permissions) {
+    for(const perm of permissions) {
         int += BigInt(2 ** array.indexOf(perm));
     }
-    return int.toString(16)
-}
+    return int.toString(16);
+};
 
 const toHexArray = (permissionsHex, array?) => {
     if (!array) {
         array = logs;
     }
-    let permissions = [];
-    let int = (BigInt("0x" + permissionsHex)).toString(2).split('').reverse();
-    for (let index in int) {
+    const permissions = [];
+    const int = (BigInt("0x" + permissionsHex)).toString(2).split("").reverse();
+    for (const index in int) {
         if (int[index] === "1" && array.length > index) {
             permissions.push(array[index]);
         }
     }
     return permissions;
-}
+};
 
 export {
     toHexInteger,
     toHexArray,
     tickets,
     logs
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/src/utils/client.ts b/src/utils/client.ts
index 3f4a8a1..a343bcb 100644
--- a/src/utils/client.ts
+++ b/src/utils/client.ts
@@ -1,9 +1,9 @@
-import { HaikuClient } from 'jshaiku';
-import { Intents } from 'discord.js';
-import config from '../config/main.json' assert {type: 'json'};
+import { HaikuClient } from "jshaiku";
+import { Intents } from "discord.js";
+import config from "../config/main.json" assert {type: "json"};
 
 const client = new HaikuClient({
-    intents: new Intents(32767).bitfield,  // This is a way of specifying all intents w/o having to type them out
+    intents: new Intents(32767).bitfield  // This is a way of specifying all intents w/o having to type them out
 }, config);
 
 export default client;
\ No newline at end of file
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index dfdc3fb..a615fae 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -1,6 +1,6 @@
 import Discord, { CommandInteraction, MessageActionRow, Message, MessageButton, TextInputComponent } from "discord.js";
 import { modalInteractionCollector } from "./dualCollector.js";
-import EmojiEmbed from "./generateEmojiEmbed.js"
+import EmojiEmbed from "./generateEmojiEmbed.js";
 import getEmojiByName from "./getEmojiByName.js";
 
 
@@ -8,7 +8,7 @@
     title: string;
     disabled: boolean;
     value: string | null;
-    emoji: string | null;
+    emoji: string | undefined;
     active: boolean;
     onClick: () => Promise<T>;
     response: T | null;
@@ -16,33 +16,33 @@
 
 class confirmationMessage {
     interaction: CommandInteraction;
-    title: string = "";
-    emoji: string = "";
-    description: string = "";
-    color: string = "";
+    title = "";
+    emoji = "";
+    description = "";
+    color = "";
     customButtons: {[index:string]: CustomBoolean<unknown>} = {};
-    inverted: boolean = false;
+    inverted = false;
     reason: string | null = null;
 
     constructor(interaction: CommandInteraction) {
         this.interaction = interaction;
     }
 
-    setTitle(title: string) { this.title = title; return this }
-    setEmoji(emoji: string) { this.emoji = emoji; return this }
-    setDescription(description: string) { this.description = description; return this }
-    setColor(color: string) { this.color = color; return this }
-    setInverted(inverted: boolean) { this.inverted = inverted; return this }
+    setTitle(title: string) { this.title = title; return this; }
+    setEmoji(emoji: string) { this.emoji = emoji; return this; }
+    setDescription(description: string) { this.description = description; return this; }
+    setColor(color: string) { this.color = color; return this; }
+    setInverted(inverted: boolean) { this.inverted = inverted; return this; }
     addCustomBoolean(customId: string, title: string, disabled: boolean, callback: () => Promise<unknown> | null, callbackClicked: string | null, emoji?: string, initial?: boolean) {        this.customButtons[customId] = {
-            title: title,
-            disabled: disabled,
-            value: callbackClicked,
-            emoji: emoji,
-            active: initial ?? false,
-            onClick: callback ?? (() => null),
-            response: null,
-        }
-        return this;
+        title: title,
+        disabled: disabled,
+        value: callbackClicked,
+        emoji: emoji,
+        active: initial ?? false,
+        onClick: callback ?? (() => null),
+        response: null
+    };
+    return this;
     }
     addReasonButton(reason: string) {
         this.reason = reason;
@@ -50,7 +50,7 @@
     }
     async send(editOnly?: boolean) {
         while (true) {
-            let fullComponents = [
+            const fullComponents = [
                 new Discord.MessageButton()
                     .setCustomId("yes")
                     .setLabel("Confirm")
@@ -61,27 +61,27 @@
                     .setLabel("Cancel")
                     .setStyle("SECONDARY")
                     .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
-            ]
+            ];
             Object.entries(this.customButtons).forEach(([k, v]) => {
                 fullComponents.push(new Discord.MessageButton()
                     .setCustomId(k)
                     .setLabel(v.title)
                     .setStyle(v.active ? "SUCCESS" : "PRIMARY")
                     .setEmoji(getEmojiByName(v.emoji, "id"))
-                    .setDisabled(v.disabled))
-            })
+                    .setDisabled(v.disabled));
+            });
             if (this.reason !== null) fullComponents.push(new Discord.MessageButton()
                 .setCustomId("reason")
-                .setLabel(`Edit Reason`)
+                .setLabel("Edit Reason")
                 .setStyle("PRIMARY")
                 .setEmoji(getEmojiByName("ICONS.EDIT", "id"))
                 .setDisabled(false)
-            )
-            let components = []
+            );
+            const components = [];
             for (let i = 0; i < fullComponents.length; i += 5) {
                 components.push(new MessageActionRow().addComponents(fullComponents.slice(i, i + 5)));
             }
-            let object = {
+            const object = {
                 embeds: [
                     new EmojiEmbed()
                         .setEmoji(this.emoji)
@@ -95,15 +95,15 @@
                 components: components,
                 ephemeral: true,
                 fetchReply: true
-            }
+            };
             let m;
             try {
                 if ( editOnly ) {
                     m = await this.interaction.editReply(object);
                 } else {
-                    m = await this.interaction.reply(object)
+                    m = await this.interaction.reply(object);
                 }
-            } catch { return { cancelled: true } }
+            } catch { return { cancelled: true }; }
             let component;
             try {
                 component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 300000});
@@ -112,17 +112,17 @@
             }
             if (component.customId === "yes") {
                 component.deferUpdate();
-                for (let [k, v] of Object.entries(this.customButtons)) {
-                    if (!v.active) continue
+                for (const v of Object.values(this.customButtons)) {
+                    if (!v.active) continue;
                     try { v.response = await v.onClick(); }
-                    catch (e) { console.log(e) }
-                };
+                    catch (e) { console.log(e); }
+                }
                 return { success: true, components: this.customButtons };
             } else if (component.customId === "no") {
                 component.deferUpdate();
                 return { success: false, components: this.customButtons };
             } else if (component.customId === "reason") {
-                await component.showModal(new Discord.Modal().setCustomId("modal").setTitle(`Editing reason`).addComponents(
+                await component.showModal(new Discord.Modal().setCustomId("modal").setTitle("Editing reason").addComponents(
                     new MessageActionRow<TextInputComponent>().addComponents(new TextInputComponent()
                         .setCustomId("reason")
                         .setLabel("Reason")
@@ -132,7 +132,7 @@
                         .setPlaceholder("Spammed in #general")
                         .setValue(this.reason ? this.reason : "")
                     )
-                ))
+                ));
                 await this.interaction.editReply({
                     embeds: [new EmojiEmbed()
                         .setTitle(this.title)
@@ -148,10 +148,10 @@
                 });
                 let out;
                 try {
-                    out = await modalInteractionCollector(m, (m) => m.channel.id === this.interaction.channel.id, (m) => m.customId === "reason")
-                } catch (e) { return {} }
+                    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 } }
+                else { return { newReason: this.reason }; }
             } else {
                 component.deferUpdate();
                 this.customButtons[component.customId].active = !this.customButtons[component.customId].active;
diff --git a/src/utils/convertCurlyBracketString.ts b/src/utils/convertCurlyBracketString.ts
index 6ffdc8f..f05076e 100644
--- a/src/utils/convertCurlyBracketString.ts
+++ b/src/utils/convertCurlyBracketString.ts
@@ -1,6 +1,6 @@
 async function convertCurlyBracketString(str, memberID, memberName, serverName, members): Promise<string> {
-    let memberCount = (await members.fetch()).size
-    let bots = (await members.fetch()).filter(m => m.user.bot).size
+    const memberCount = (await members.fetch()).size;
+    const bots = (await members.fetch()).filter(m => m.user.bot).size;
     str = str
         .replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}")
         .replace("{member:name}", memberName ? `${memberName}` : "{member:name}")
@@ -9,7 +9,7 @@
         .replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}")
         .replace("{memberCount:humans}", (memberCount && bots) ? `${memberCount - bots}` : "{memberCount:humans}");
 
-    return str
+    return str;
 }
 
 export default convertCurlyBracketString;
diff --git a/src/utils/createLogException.ts b/src/utils/createLogException.ts
index 0223d2f..c62a824 100644
--- a/src/utils/createLogException.ts
+++ b/src/utils/createLogException.ts
@@ -3,6 +3,6 @@
 export default function (guild: string, channel: string, message: string) {
     client.noLog.push(`${guild}/${channel}/${message}`);
     setTimeout(() => {
-        client.noLog = client.noLog.filter((i) => {return i !== `${guild}/${channel}/${message}`});
+        client.noLog = client.noLog.filter((i) => {return i !== `${guild}/${channel}/${message}`;});
     }, 500);
 }
\ No newline at end of file
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 8a5ca6f..cffdf04 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -1,57 +1,68 @@
-import Discord from 'discord.js';
-import { Collection, MongoClient } from 'mongodb';
-import structuredClone from '@ungap/structured-clone';
-import config from '../config/main.json' assert {type: 'json'};
+import type Discord from "discord.js";
+import { Collection, MongoClient } from "mongodb";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import structuredClone from "@ungap/structured-clone";
+import config from "../config/main.json" assert {type: "json"};
 
 
 const mongoClient = new MongoClient(config.mongoUrl);
-await mongoClient.connect()
+await mongoClient.connect();
 const database = mongoClient.db("Nucleus");
 
-
-export const Entry = data => {
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export const Entry = (data: any) => {
     data = data ?? {};
-    data.getKey = key => data[key]
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    data.getKey = (key: any) => data[key];
     return {
-        get(target, prop, receiver) {
-            let dataToReturn = data[prop]
+        // eslint-disable-next-line @typescript-eslint/no-explicit-any
+        get(target: Record<string, any>, prop: string, receiver: any) {
+            let dataToReturn = data[prop];
             if (dataToReturn === null ) return Reflect.get(target, prop, receiver);
             if (typeof dataToReturn === "object" && !Array.isArray(dataToReturn)) dataToReturn = new Proxy(
                 Reflect.get(target, prop, receiver),
-                Entry(dataToReturn),
-            )
+                Entry(dataToReturn)
+            );
             return dataToReturn ?? Reflect.get(target, prop, receiver);
         }
-    }
-}
+    };
+};
 
 
 export class Guilds {
     guilds: Collection<GuildConfig>;
-    defaultData: GuildConfig;
-    async setup() {
+    defaultData: GuildConfig | null;
+
+    constructor() {
         this.guilds = database.collection<GuildConfig>("guilds");
-        this.defaultData = (await import("../config/default.json", { assert: { type: "json" }})).default as unknown as GuildConfig;
+        this.defaultData = null;
         return this;
     }
 
+    async setup() {
+        this.defaultData = (await import("../config/default.json", { assert: { type: "json" }})).default as unknown as GuildConfig;
+    }
+
     async read(guild: string) {
-        let entry = await this.guilds.findOne({ id: guild });
-        return new Proxy(structuredClone(this.defaultData), Entry(entry)) as unknown as GuildConfig
+        const entry = await this.guilds.findOne({ id: guild });
+        return new Proxy(structuredClone(this.defaultData), Entry(entry)) as unknown as GuildConfig;
     }
 
     async write(guild: string, set: object | null, unset: string[] | string = []) {
-        let uo = {}
-        if (!Array.isArray(unset)) unset = [unset]
-        for (let key of unset) {
+        // eslint-disable-next-line @typescript-eslint/no-explicit-any
+        const uo: Record<string, any> = {};
+        if (!Array.isArray(unset)) unset = [unset];
+        for (const key of unset) {
             uo[key] = null;
         }
-        let out = {$set: {}, $unset: {}}
+        const out = {$set: {}, $unset: {}};
         if (set) out["$set"] = set;
         if (unset.length) out["$unset"] = uo;
         await this.guilds.updateOne({ id: guild }, out, { upsert: true });
     }
 
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
     async append(guild: string, key: string, value: any) {
         if (Array.isArray(value)) {
             await this.guilds.updateOne({ id: guild }, {
@@ -64,8 +75,9 @@
         }
     }
 
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
     async remove(guild: string, key: string, value: any, innerKey?: string | null) {
-        console.log(Array.isArray(value))
+        console.log(Array.isArray(value));
         if (innerKey) {
             await this.guilds.updateOne({ id: guild }, {
                 $pull: { [key]: { [innerKey]: { $eq: value } } }
@@ -111,7 +123,7 @@
     }
 
     async read(guild: string, user: string, year: number) {
-        let entry = (await this.histories.find({
+        const entry = (await this.histories.find({
             guild: guild,
             user: user,
             occurredAt: {
@@ -141,7 +153,7 @@
     }
 
     async read(guild: string, user: string) {
-        let entry = await this.modNotes.findOne({ guild: guild, user: user });
+        const entry = await this.modNotes.findOne({ guild: guild, user: user });
         return entry?.note ?? null;
     }
 }
@@ -155,7 +167,7 @@
     }
 
     async hasPremium(guild: string) {
-        let entry = await this.premium.findOne({ appliesTo: { $in: [guild] } });
+        const entry = await this.premium.findOne({ appliesTo: { $in: [guild] } });
         return entry !== null;
     }
 }
@@ -186,11 +198,7 @@
         },
         invite: {
             enabled: boolean,
-            allowed: {
-                users: string[],
-                channels: string[],
-                roles: string[]
-            }
+            channels: string[]
         },
         pings: {
             mass: number,
@@ -215,7 +223,7 @@
         channel: string | null,
         message: string | null,
     }
-    stats: {}
+    stats: Record<string, {name: string, enabled: boolean}>
     logging: {
         logs: {
             enabled: boolean,
@@ -227,7 +235,7 @@
         },
         attachments: {
             channel: string | null,
-            saved: {}  // {channelID+messageID: log url (string)}
+            saved: Record<string, string>
         }
     }
     verify: {
@@ -292,8 +300,8 @@
             }[]
         }[]
     }
-    tags: {}
-};
+    tags: Record<string, string>
+}
 
 export interface HistorySchema {
     type: string,
diff --git a/src/utils/defaultEmbeds.ts b/src/utils/defaultEmbeds.ts
index e799307..ce6edc1 100644
--- a/src/utils/defaultEmbeds.ts
+++ b/src/utils/defaultEmbeds.ts
@@ -1,9 +1,9 @@
-import EmojiEmbed from "./generateEmojiEmbed.js"
+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/dualCollector.ts b/src/utils/dualCollector.ts
index 67cef5c..c785d0a 100644
--- a/src/utils/dualCollector.ts
+++ b/src/utils/dualCollector.ts
@@ -1,21 +1,19 @@
-import Discord from 'discord.js';
-import client from './client.js';
-import EmojiEmbed from "./generateEmojiEmbed.js";
+import Discord from "discord.js";
+import client from "./client.js";
 
 export default async function (m, interactionFilter, messageFilter) {
     let out;
     try {
-        out = await new Promise((resolve, reject) => {
-            let mes, int;
-            mes = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 300000})
-                .on("collect", (m) => { resolve(m); })
-            int = m.channel.createMessageCollector({filter: (m) => messageFilter(m), time: 300000})
-                .then("collect", (m) => { try {m.delete();} catch {}; resolve(m); })
-            mes.on("end", () => { int.stop(); })
-            int.on("end", () => { mes.stop(); })
-        })
+        out = await new Promise((resolve, _reject) => {
+            const mes = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 300000})
+                .on("collect", (m) => { resolve(m); });
+            const int = m.channel.createMessageCollector({filter: (m) => messageFilter(m), time: 300000})
+                .then("collect", (m) => { try {m.delete();} catch (e) { client._error(e); } resolve(m); });
+            mes.on("end", () => { int.stop(); });
+            int.on("end", () => { mes.stop(); });
+        });
     } catch(e) {
-        console.log(e)
+        console.log(e);
         return null;
     }
 
@@ -25,24 +23,23 @@
 export async function modalInteractionCollector(m, modalFilter, interactionFilter) {
     let out;
     try {
-        out = await new Promise((resolve, reject) => {
-            let mod, int;
-            int = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 300000})
-                .on("collect", (m) => { resolve(m); })
-            mod = new Discord.InteractionCollector(
+        out = await new Promise((resolve, _reject) => {
+            const int = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 300000})
+                .on("collect", (m) => { resolve(m); });
+            const mod = new Discord.InteractionCollector(
                 client, {
                     filter: (m) => modalFilter(m),
                     time: 300000
                 })
                 .on("collect", async (m) => {
                     int.stop();
-                    (m as Discord.ModalSubmitInteraction).deferUpdate()
-                    resolve((m as Discord.ModalSubmitInteraction)); })
-            int.on("end", () => { mod.stop(); })
-            mod.on("end", () => { int.stop(); })
-        })
+                    (m as Discord.ModalSubmitInteraction).deferUpdate();
+                    resolve((m as Discord.ModalSubmitInteraction)); });
+            int.on("end", () => { mod.stop(); });
+            mod.on("end", () => { int.stop(); });
+        });
     } catch(e) {
-        console.log(e)
+        console.log(e);
         return null;
     }
     return out;
diff --git a/src/utils/eventScheduler.ts b/src/utils/eventScheduler.ts
index 396b202..cde178f 100644
--- a/src/utils/eventScheduler.ts
+++ b/src/utils/eventScheduler.ts
@@ -1,39 +1,39 @@
 import { Agenda } from "agenda/es.js";
-import client from './client.js';
-import * as fs from 'fs';
-import * as path from 'path';
-import config from '../config/main.json' assert {type: 'json'};
+import client from "./client.js";
+import * as fs from "fs";
+import * as path from "path";
+import config from "../config/main.json" assert {type: "json"};
 
 class EventScheduler {
     private agenda: Agenda;
 
     constructor() {
-        this.agenda = new Agenda({db: {address: config.mongoUrl + "Nucleus", collection: 'eventScheduler'}})
+        this.agenda = new Agenda({db: {address: config.mongoUrl + "Nucleus", collection: "eventScheduler"}});
 
         this.agenda.define("unmuteRole", async (job: Agenda.job) => {
-            let guild = await client.guilds.fetch(job.attrs.data.guild);
-            let user = await guild.members.fetch(job.attrs.data.user);
-            let role = await guild.roles.fetch(job.attrs.data.role);
+            const guild = await client.guilds.fetch(job.attrs.data.guild);
+            const user = await guild.members.fetch(job.attrs.data.user);
+            const role = await guild.roles.fetch(job.attrs.data.role);
             await user.roles.remove(role);
             await job.remove();
-        })
+        });
         this.agenda.define("deleteFile", async (job: Agenda.job) => {
-            fs.rm(path.resolve("dist/utils/temp", job.attrs.data.fileName), (err) => {})
+            fs.rm(path.resolve("dist/utils/temp", job.attrs.data.fileName), client._error);
             await job.remove();
-        })
+        });
         this.agenda.define("naturalUnmute", async (job: Agenda.job) => {
-            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger
-            let guild = await client.guilds.fetch(job.attrs.data.guild);
-            let user = await guild.members.fetch(job.attrs.data.user);
-            if (user.communicationDisabledUntil === null) return
+            const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+            const guild = await client.guilds.fetch(job.attrs.data.guild);
+            const user = await guild.members.fetch(job.attrs.data.user);
+            if (user.communicationDisabledUntil === null) return;
             try { await client.database.history.create(
                 "unmute", user.guild.id, user.user, null, null, null, null
-            )} catch {}
-            let data = {
+            );} catch (e) { client._error(e); }
+            const data = {
                 meta: {
-                    type: 'memberUnmute',
-                    displayName: 'Unmuted',
-                    calculateType: 'guildMemberPunish',
+                    type: "memberUnmute",
+                    displayName: "Unmuted",
+                    calculateType: "guildMemberPunish",
                     color: NucleusColors.green,
                     emoji: "PUNISH.MUTE.GREEN",
                     timestamp: new Date().getTime()
@@ -47,23 +47,25 @@
                 hidden: {
                     guild: guild.id
                 }
-            }
+            };
             log(data);
-        })
+        });
     }
 
     async start() {
-        await new Promise(resolve => this.agenda.once('ready', resolve));
-        this.agenda.start()
-        return this
+        await new Promise(resolve => this.agenda.once("ready", resolve));
+        this.agenda.start();
+        return this;
     }
 
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
     async schedule(name: string, time: string, data: any) {
-        await this.agenda.schedule(time, name, data)
+        await this.agenda.schedule(time, name, data);
     }
 
-    cancel(name: string, data: Object) {
-        this.agenda.cancel({name, data})
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    cancel(name: string, data: any) {
+        this.agenda.cancel({name, data});
     }
 }
 
diff --git a/src/utils/generateEmojiEmbed.ts b/src/utils/generateEmojiEmbed.ts
index 8fe594b..7587db7 100644
--- a/src/utils/generateEmojiEmbed.ts
+++ b/src/utils/generateEmojiEmbed.ts
@@ -1,16 +1,17 @@
-import Discord, { CommandInteraction, ColorResolvable, MessageEmbed } from "discord.js";
+import { MessageEmbed } from "discord.js";
 import getEmojiByName from "./getEmojiByName.js";
 
 const colors = {
     "Danger": 0xF27878,
     "Warning": 0xF2D478,
     "Success": 0x68D49E
-}
+};
 
 class EmojiEmbed extends MessageEmbed {
     _title: string;
     _emoji: string;
 
+    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
     // @ts-ignore
     // This *is* meant to be an accessor rather than a property
     get title() {
@@ -21,9 +22,9 @@
         this._title = title;
     }
 
-    setTitle(title: string) { this._title = title; return this }
-    setEmoji(emoji: string) { this._emoji = emoji; return this }
-    setStatus(color: string) { this.setColor(colors[color]); return this }
+    setTitle(title: string) { this._title = title; return this; }
+    setEmoji(emoji: string) { this._emoji = emoji; return this; }
+    setStatus(color: string) { this.setColor(colors[color]); return this; }
 }
 
 export default EmojiEmbed;
\ No newline at end of file
diff --git a/src/utils/generateKeyValueList.ts b/src/utils/generateKeyValueList.ts
index 1a76fa7..ecb9780 100644
--- a/src/utils/generateKeyValueList.ts
+++ b/src/utils/generateKeyValueList.ts
@@ -2,17 +2,17 @@
     "ID",
     "NSFW",
     "URL"
-]
+];
 
 export function capitalize(s: string) {
-    s = s.replace(/([A-Z])/g, ' $1');
+    s = s.replace(/([A-Z])/g, " $1");
     s = s.split(" ").map(word => {
         return forceCaps.includes(word.toUpperCase()) ? word.toUpperCase() : word[0]
             .toUpperCase() + word.slice(1)
             .toLowerCase()
-            .replace("discord", "Discord")
+            .replace("discord", "Discord");
     }).join(" ");
-    return s
+    return s;
 }
 
 export function toCapitals(s: string) {
@@ -22,8 +22,8 @@
 function keyValueList(data) {
     let out = "";
     Object.entries(data).map(([key, value]) => {
-        out += `**${capitalize(key)}:** ${value}\n`
-    })
+        out += `**${capitalize(key)}:** ${value}\n`;
+    });
     return out;
 }
 
diff --git a/src/utils/getEmojiByName.ts b/src/utils/getEmojiByName.ts
index 80410df..63b2042 100644
--- a/src/utils/getEmojiByName.ts
+++ b/src/utils/getEmojiByName.ts
@@ -1,8 +1,8 @@
-import emojis from '../config/emojis.json' assert {type: 'json'};
+import emojis from "../config/emojis.json" assert {type: "json"};
 
 function getEmojiByName(name: string, format?: string): string {
-    let split = name.split(".");
-    let id = emojis
+    const split = name.split(".");
+    let id = emojis;
     split.forEach(part => {
         id = id[part];
     });
@@ -11,9 +11,9 @@
         return id.toString();
     }
     if (id === undefined) {
-        return `<a:_:946346549271732234>`
+        return "<a:_:946346549271732234>";
     } else if (id.toString().startsWith("a")) {
-        return `<a:_:${id.toString().slice(1, id.toString().length)}>`
+        return `<a:_:${id.toString().slice(1, id.toString().length)}>`;
     }
     return `<:_:${id}>`;
 }
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 0c6aa89..34b24c6 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -1,33 +1,32 @@
-import * as fs from 'fs';
-import * as Discord from 'discord.js';
-import getEmojiByName from './getEmojiByName.js';
-import { toHexArray } from './calculate.js';
-import { promisify } from 'util';
-import generateKeyValueList from './generateKeyValueList.js';
-import client from './client.js';
+import * as Discord from "discord.js";
+import getEmojiByName from "./getEmojiByName.js";
+import { toHexArray } from "./calculate.js";
+import { promisify } from "util";
+import generateKeyValueList from "./generateKeyValueList.js";
+import client from "./client.js";
 
 const wait = promisify(setTimeout);
 
 
 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) {
-        t = Math.floor(t /= 1000)
+        t = Math.floor(t /= 1000);
         return `<t:${t}:D> at <t:${t}:T>`;
     }
     renderDelta(t: number) {
-        t = Math.floor(t /= 1000)
+        t = Math.floor(t /= 1000);
         return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
     }
     renderNumberDelta(num1, num2) {
-        let delta = num2 - num1;
-        return `${num1} -> ${num2} (${delta > 0 ? '+' : ''}${delta})`;
+        const delta = num2 - num1;
+        return `${num1} -> ${num2} (${delta > 0 ? "+" : ""}${delta})`;
     }
     entry(value, displayValue) {
-        return { value: value, displayValue: displayValue }
+        return { value: value, displayValue: displayValue };
     }
     renderChannel(channel: Discord.GuildChannel | Discord.ThreadChannel) {
         return `${channel.name} [<#${channel.id}>]`;
@@ -36,43 +35,45 @@
         return `${role.name} [<@&${role.id}>]`;
     }
     renderEmoji(emoji: Discord.GuildEmoji) {
-        return `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
+        return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
     }
 
     public readonly NucleusColors = {
         red: 0xF27878,
         yellow: 0xF2D478,
-        green: 0x68D49E,
+        green: 0x68D49E
 
-    }
+    };
 
     async getAuditLog(guild: Discord.Guild, event): Promise<Discord.GuildAuditLogsEntry[]>{
-        await wait(250)
-        let auditLog = await guild.fetchAuditLogs({type: event});
+        await wait(250);
+        const auditLog = await guild.fetchAuditLogs({type: event});
         return auditLog as unknown as Discord.GuildAuditLogsEntry[];
     }
 
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
     async log(log: any): Promise<void> {
-        let config = await client.database.guilds.read(log.hidden.guild);
+        const config = await client.database.guilds.read(log.hidden.guild);
         if (!config.logging.logs.enabled) return;
         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(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log("Not logging this type of event");
         }
         if (config.logging.logs.channel) {
-            let channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
-            let description = {};
+            const channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
+            const description = {};
             Object.entries(log.list).map(entry => {
-                let key = entry[0];
-                let value:any = entry[1];
+                const key = entry[0];
+                // eslint-disable-next-line @typescript-eslint/no-explicit-any
+                const value: any = entry[1];
                 if(value.displayValue) {
                     description[key] = value.displayValue;
                 } else {
                     description[key] = value;
                 }
-            })
+            });
             if (channel) {
                 log.separate = log.separate || {};
-                let embed = new Discord.MessageEmbed()
+                const embed = new Discord.MessageEmbed()
                     .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
                     .setDescription(
                         (log.separate.start ? log.separate.start + "\n" : "") +
@@ -88,4 +89,4 @@
 }
 
 
-export default {}
+export default {};
diff --git a/src/utils/memory.ts b/src/utils/memory.ts
index a06705b..070bd7f 100644
--- a/src/utils/memory.ts
+++ b/src/utils/memory.ts
@@ -1,29 +1,30 @@
 import client from "./client.js";
 
 class Memory {
-    memory: {};
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    memory: Record<string, any>;
     constructor() {
         this.memory = {};
 
         setInterval(() => {
-            for (let guild in this.memory) {
+            for (const guild in this.memory) {
                 if (this.memory[guild].updated + 15 * 60 * 1000 < Date.now()) {
                     delete this.memory[guild];
                 }
             }
-        }, 1000 * 60 * 30)
+        }, 1000 * 60 * 30);
     }
 
     async readGuildInfo(guild: string): Promise<object> {
         if (!this.memory[guild]) {
-            let guildData = await client.database.guilds.read(guild);
+            const guildData = await client.database.guilds.read(guild);
             this.memory[guild] = {
                 lastUpdated: Date.now(),
                 filters: guildData.filters,
                 logging: guildData.logging,
-                tickets: guildData.tickets,
+                tickets: guildData.tickets
             };
-        };
+        }
         return this.memory[guild];
     }
 }
diff --git a/src/utils/plurals.ts b/src/utils/plurals.ts
index 48b889c..619ced2 100644
--- a/src/utils/plurals.ts
+++ b/src/utils/plurals.ts
@@ -1,7 +1,7 @@
-function addPlural(amount: any, unit: string) {
+function addPlural(amount: number | string, unit: string) {
     amount = amount.toString();
-    if (amount === '1') return `${amount} ${unit}`
-    return `${amount} ${unit}s`
+    if (amount === "1") return `${amount} ${unit}`;
+    return `${amount} ${unit}s`;
 }
 
 export default addPlural;
\ No newline at end of file
diff --git a/src/utils/singleNotify.ts b/src/utils/singleNotify.ts
index f29d775..44bb2d0 100644
--- a/src/utils/singleNotify.ts
+++ b/src/utils/singleNotify.ts
@@ -1,29 +1,29 @@
-import client from './client.js';
+import client from "./client.js";
 import EmojiEmbed from "./generateEmojiEmbed.js";
 
-let severities = {
+const severities = {
     "Critical": "Danger",
     "Warning": "Warning",
     "Info": "Success"
-}
+};
 
 export default async function(type: string, guild: string, message: string | true, severity?: string) {
-    let data = await client.database.guilds.read(guild);
+    const 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;
     await client.database.guilds.write(guild, {[`singleEventNotifications.${type}`]: true});
     try {
-        let channel = await client.channels.fetch(data.logging.staff.channel);
+        const channel = await client.channels.fetch(data.logging.staff.channel);
         if (!channel) return;
         await channel.send({embeds: [new EmojiEmbed()
             .setTitle(`${severity} notification`)
             .setDescription(message)
             .setStatus(severities[severity])
             .setEmoji("CONTROL.BLOCKCROSS")
-        ]})
+        ]});
     } catch (err) {
-        console.error(err)
+        console.error(err);
     }
 }
diff --git a/src/utils/temp/generateFileName.ts b/src/utils/temp/generateFileName.ts
index f9662ad..8a219b7 100644
--- a/src/utils/temp/generateFileName.ts
+++ b/src/utils/temp/generateFileName.ts
@@ -1,17 +1,17 @@
-import * as fs from 'fs';
-import * as crypto from 'crypto';
-import client from '../client.js';
-import * as path from 'path'
-import {fileURLToPath} from 'url';
+import * as fs from "fs";
+import * as crypto from "crypto";
+import client from "../client.js";
+import * as path from "path";
+import {fileURLToPath} from "url";
 const __filename = fileURLToPath(import.meta.url);
 const __dirname = path.dirname(__filename);
 
 export default function generateFileName(ending: string): string {
-    let fileName = crypto.randomBytes(35).toString('hex');
-    fileName = fileName.replace(/([a-zA-Z0-9]{8})/g, '$1-');
+    let fileName = crypto.randomBytes(35).toString("hex");
+    fileName = fileName.replace(/([a-zA-Z0-9]{8})/g, "$1-");
     if (fs.existsSync(`./${fileName}`)) {
         fileName = generateFileName(ending);
     }
     client.database.eventScheduler.schedule("deleteFile", new Date().getTime() + (60 * 1000), {fileName: `${fileName}.${ending}`});
-    return path.join(__dirname, fileName + '.' + ending);
+    return path.join(__dirname, fileName + "." + ending);
 }
