diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 51be5cb..453a467 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -1,5 +1,11 @@
 import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, {
+    CommandInteraction,
+    GuildMember,
+    MessageActionRow,
+    MessageButton,
+    MessageSelectMenu
+} from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -17,13 +23,23 @@
     data: object;
     checkFunction: (member) => boolean;
     inverted = false;
-    constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
-        if (typeof name === "function") { this.name = name(data);
-        } else { this.name = name; }
+    constructor(
+        name: (data) => string | string,
+        data: object,
+        check: (member) => boolean
+    ) {
+        if (typeof name === "function") {
+            this.name = name(data);
+        } else {
+            this.name = name;
+        }
         this.data = data;
         this.checkFunction = check;
     }
-    flip() { this.inverted = true; return this; }
+    flip() {
+        this.inverted = true;
+        return this;
+    }
     check(member) {
         if (this.inverted) return !this.checkFunction(member);
         else return this.checkFunction(member);
@@ -35,51 +51,130 @@
         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();
-            }))
+            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();
+                    }
+                )
         },
         nickname: {
             render: "Nickname",
-            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);})),
-            startsWith: (name) => ( new Filter((_data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
-                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);}))
+            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);
+                    }
+                ),
+            startsWith: (name) =>
+                new Filter(
+                    (_data) => `Nickname starts with "${name}"`,
+                    { nickname: name, type: String, render: "starts with" },
+                    (member) => {
+                        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);
+                    }
+                )
         }
     },
     account: {
         render: "Account",
         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();
-            }))
+            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();
+                    }
+                )
         },
         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);})),
-            startsWith: (name) => ( new Filter((_data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
-                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);}))
+            includes: (name) =>
+                new Filter(
+                    (_data) => `Nickname includes "${name}"`,
+                    { nickname: name, type: String, render: "includes" },
+                    (member) => {
+                        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);
+                    }
+                ),
+            endsWith: (name) =>
+                new Filter(
+                    (_data) => `Nickname ends with "${name}"`,
+                    { nickname: name, type: String, render: "ends with" },
+                    (member) => {
+                        return member.user.name.endsWith(name);
+                    }
+                )
         }
     }
 };
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    await interaction.reply({
+        embeds: LoadingEmbed,
+        ephemeral: true,
+        fetchReply: true
+    });
     const filters: Filter[] = [
         filterList.member.has.role("959901346000154674"),
         filterList.member.nickname.startsWith("Pinea"),
@@ -91,65 +186,122 @@
         const affected = [];
         const members = interaction.guild.members.cache;
         if (all) {
-            members.forEach(member => {
+            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 => {
+            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")
-            .setDescription((all ? "All of the following must be true:" : "Any of the following must be true") + "\n" +
-                filters.map((f) => {
-                    count ++;
-                    return (count === 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
-                        (f.inverted ? "**not** " : "") + `${f.name}`;
-                }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
-            .setEmoji("GUILD.ROLES.CREATE")
-            .setStatus("Success")
-        ], components: [
-            new MessageActionRow().addComponents([new MessageSelectMenu().setOptions(filters.map((f, index) => ({
-                label: (f.inverted ? "(Not) " : "") + f.name,
-                value: index.toString()
-            }))).setMinValues(1).setMaxValues(filters.length).setCustomId("select").setPlaceholder("Remove a filter")]),
-            new MessageActionRow().addComponents([
-                new MessageButton()
-                    .setLabel("Apply")
-                    .setStyle("PRIMARY")
-                    .setCustomId("apply")
-                    .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id")))
-                    .setDisabled(affected.length === 0),
-                new MessageButton()
-                    .setLabel("Add filter")
-                    .setStyle("PRIMARY")
-                    .setCustomId("add")
-                    .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
-                    .setDisabled(filters.length >= 25)
-            ])
-        ]});
+        await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Role all")
+                    .setDescription(
+                        (all
+                            ? "All of the following must be true:"
+                            : "Any of the following must be true") +
+                            "\n" +
+                            filters
+                                .map((f) => {
+                                    count++;
+                                    return (
+                                        (count === 1
+                                            ? getEmojiByName("ICONS.FILTER")
+                                            : all
+                                            ? "**and** "
+                                            : "**or** ") +
+                                        (f.inverted ? "**not** " : "") +
+                                        `${f.name}`
+                                    );
+                                })
+                                .join("\n") +
+                            "\n\n" +
+                            `This will affect ${addPlural(
+                                affected.length,
+                                "member"
+                            )}`
+                    )
+                    .setEmoji("GUILD.ROLES.CREATE")
+                    .setStatus("Success")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageSelectMenu()
+                        .setOptions(
+                            filters.map((f, index) => ({
+                                label: (f.inverted ? "(Not) " : "") + f.name,
+                                value: index.toString()
+                            }))
+                        )
+                        .setMinValues(1)
+                        .setMaxValues(filters.length)
+                        .setCustomId("select")
+                        .setPlaceholder("Remove a filter")
+                ]),
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel("Apply")
+                        .setStyle("PRIMARY")
+                        .setCustomId("apply")
+                        .setEmoji(
+                            client.emojis.cache.get(
+                                getEmojiByName("CONTROL.TICK", "id")
+                            )
+                        )
+                        .setDisabled(affected.length === 0),
+                    new MessageButton()
+                        .setLabel("Add filter")
+                        .setStyle("PRIMARY")
+                        .setCustomId("add")
+                        .setEmoji(
+                            client.emojis.cache.get(
+                                getEmojiByName("ICONS.FILTER", "id")
+                            )
+                        )
+                        .setDisabled(filters.length >= 25)
+                ])
+            ]
+        });
         break;
     }
     return;
 };
 
-const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
-    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";
+const check = async (
+    interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
+    const member = interaction.member as GuildMember;
+    const me = interaction.guild.me!;
+    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;
     // Check if the user has manage_roles permission
-    if (! member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
+    if (!member.permissions.has("MANAGE_ROLES"))
+        throw "You do not have the *Manage Roles* permission";
     // Allow role
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
index 4ba582d..e4346d6 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,5 +1,11 @@
 import { LoadingEmbed } from "../utils/defaultEmbeds.js";
-import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.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";
@@ -11,10 +17,14 @@
     .setName("categorise")
     .setDescription("Categorises your servers channels");
 
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
-    const channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
+const callback = async (
+    interaction: CommandInteraction
+): Promise<void | unknown> => {
+    const channels = interaction.guild.channels.cache.filter(
+        (c) => c.type !== "GUILD_CATEGORY"
+    );
     const categorised = {};
-    await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+    await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
     const predicted = {};
     const types = {
         general: ["general", "muted", "main", "topic", "discuss"],
@@ -41,58 +51,110 @@
     for (const c of channels) {
         // convert channel to a channel if its a string
         let channel: string | GuildChannel;
-        if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel as string).id;
+        if (typeof c === "string")
+            channel = interaction.guild.channels.cache.get(
+                channel as string
+            ).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` +
-            `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
-            .setEmoji("CHANNEL.CATEGORY.CREATE")
-            .setStatus("Success")
-        ], components: [
-            new MessageActionRow().addComponents([new MessageSelectMenu()
-                .setCustomId("selected")
-                .setMaxValues(Object.keys(types).length)
-                .setMinValues(1)
-                .setPlaceholder("Select all types that apply to this channel")
-                .setOptions(Object.keys(types).map(type => ({label: type, value: type})))
-            ]),
-            new MessageActionRow().addComponents([
-                new MessageButton().setLabel("Accept Suggestion").setCustomId("accept").setStyle("SUCCESS").setDisabled(predicted[channel].length === 0)
-                    .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id"))),
-                new MessageButton().setLabel("Use \"Other\"").setCustomId("reject").setStyle("SECONDARY")
-                    .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
-            ])
-        ]});
+        m = await interaction.editReply({
+            embeds: [
+                new EmojiEmbed()
+                    .setTitle("Categorise")
+                    .setDescription(
+                        `Select all types that apply to <#${channel}>.\n\n` +
+                            `${addPlural(
+                                predicted[channel].length,
+                                "Suggestion"
+                            )}: ${predicted[channel].join(", ")}`
+                    )
+                    .setEmoji("CHANNEL.CATEGORY.CREATE")
+                    .setStatus("Success")
+            ],
+            components: [
+                new MessageActionRow().addComponents([
+                    new MessageSelectMenu()
+                        .setCustomId("selected")
+                        .setMaxValues(Object.keys(types).length)
+                        .setMinValues(1)
+                        .setPlaceholder(
+                            "Select all types that apply to this channel"
+                        )
+                        .setOptions(
+                            Object.keys(types).map((type) => ({
+                                label: type,
+                                value: type
+                            }))
+                        )
+                ]),
+                new MessageActionRow().addComponents([
+                    new MessageButton()
+                        .setLabel("Accept Suggestion")
+                        .setCustomId("accept")
+                        .setStyle("SUCCESS")
+                        .setDisabled(predicted[channel].length === 0)
+                        .setEmoji(
+                            client.emojis.cache.get(
+                                getEmojiByName("ICONS.TICK", "id")
+                            )
+                        ),
+                    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 });
         } catch (e) {
-            return await interaction.editReply({embeds: [new EmojiEmbed()
-                .setTitle("Categorise")
-                .setEmoji("CHANNEL.CATEGORY.DELETE")
-                .setStatus("Danger")
-                .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
-                `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
-                .setFooter({text: "Message timed out"})
-            ]});
+            return await interaction.editReply({
+                embeds: [
+                    new EmojiEmbed()
+                        .setTitle("Categorise")
+                        .setEmoji("CHANNEL.CATEGORY.DELETE")
+                        .setStatus("Danger")
+                        .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();
         let selected;
-        if (i.customId === "select") { selected = i.values; }
-        if (i.customId === "accept") { selected = predicted[channel]; }
-        if (i.customId === "reject") { selected = ["other"]; }
+        if (i.customId === "select") {
+            selected = i.values;
+        }
+        if (i.customId === "accept") {
+            selected = predicted[channel];
+        }
+        if (i.customId === "reject") {
+            selected = ["other"];
+        }
         categorised[channel] = selected;
     }
     console.log(categorised);
 };
 
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+    _interaction: CommandInteraction,
+    _defaultCheck: WrappedCheck
+) => {
     return true;
 };
 
 export { command };
 export { callback };
-export { check };
\ No newline at end of file
+export { check };
