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