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