Development (#11)

We need this NOW.

---------

Co-authored-by: PineaFan <ash@pinea.dev>
Co-authored-by: pineafan <pineapplefanyt@gmail.com>
Co-authored-by: PineappleFan <PineaFan@users.noreply.github.com>
Co-authored-by: Skyler <skyler3665@gmail.com>
diff --git a/src/utils/commandRegistration/slashCommandBuilder.ts b/src/utils/commandRegistration/slashCommandBuilder.ts
index b2927d6..66291b3 100644
--- a/src/utils/commandRegistration/slashCommandBuilder.ts
+++ b/src/utils/commandRegistration/slashCommandBuilder.ts
@@ -1,12 +1,12 @@
-import type { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
+import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from "discord.js";
 import type { SlashCommandBuilder } from "discord.js";
-import config from "../../config/main.json" assert { type: "json" };
+import config from "../../config/main.js";
 import getSubcommandsInFolder from "./getFilesInFolder.js";
 import client from "../client.js";
 import Discord from "discord.js";
 
 
-const colours = {
+const colors = {
     red: "\x1b[31m",
     green: "\x1b[32m",
     none: "\x1b[0m"
@@ -23,7 +23,7 @@
     // If the name of the command does not match the path (e.g. attachment.ts has /attachments), use commandString
     console.log(`│  ├─ Loading group ${name}`)
     const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path, "│  ")
-    console.log(`│  │  └─ ${fetched.errors ? colours.red : colours.green}Loaded ${fetched.subcommands.length} subcommands for ${name} (${fetched.errors} failed)${colours.none}`)
+    console.log(`│  │  └─ ${fetched.errors ? colors.red : colors.green}Loaded ${fetched.subcommands.length} subcommands for ${name} (${fetched.errors} failed)${colors.none}`)
     return (subcommandGroup: SlashCommandSubcommandGroupBuilder) => {
         subcommandGroup
             .setName(name)
@@ -32,7 +32,9 @@
         if (descriptionLocalizations) { subcommandGroup.setDescriptionLocalizations(descriptionLocalizations) }
 
         for (const subcommand of fetched.subcommands) {
-            subcommandGroup.addSubcommand(subcommand.command);
+            const processedCommand = subcommand.command(new SlashCommandSubcommandBuilder());
+            client.commands["commands/" + path + "/" + processedCommand.name] = [subcommand, { name: processedCommand.name, description: processedCommand.description }]
+            subcommandGroup.addSubcommand(processedCommand);
         };
 
         return subcommandGroup;
@@ -52,7 +54,9 @@
     // If the name of the command does not match the path (e.g. attachment.ts has /attachments), use commandString
     commandString = "commands/" + (commandString ?? path);
     const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path);
-    console.log(`│  ├─ ${fetched.errors ? colours.red : colours.green}Loaded ${fetched.subcommands.length} subcommands and ${fetched.subcommandGroups.length} subcommand groups for ${name} (${fetched.errors} failed)${colours.none}`)
+    console.log(`│  ├─ ${fetched.errors ? colors.red : colors.green}Loaded ${fetched.subcommands.length} subcommands and ${fetched.subcommandGroups.length} subcommand groups for ${name} (${fetched.errors} failed)${colors.none}`)
+    // console.log({name: name, description: description})
+    client.commands[commandString!] = [undefined, { name: name, description: description }]
     return (command: SlashCommandBuilder) => {
         command.setName(name)
         command.setDescription(description)
@@ -68,15 +72,17 @@
         for (const subcommand of fetched.subcommands) {
             let fetchedCommand;
             if (subcommand.command instanceof Function) {
-                fetchedCommand = subcommand.command(new Discord.SlashCommandSubcommandBuilder());
+                fetchedCommand = subcommand.command(new SlashCommandSubcommandBuilder());
             } else {
                 fetchedCommand = subcommand.command;
             }
-            client.commands[commandString! + "/" + fetchedCommand.name] = subcommand
+            client.commands[commandString! + "/" + fetchedCommand.name] = [subcommand, { name: fetchedCommand.name, description: fetchedCommand.description }]
             command.addSubcommand(fetchedCommand);
         }
         for (const group of fetched.subcommandGroups) {
-            command.addSubcommandGroup(group.command);
+            const processedCommand = group.command(new SlashCommandSubcommandGroupBuilder());
+            client.commands[commandString! + "/" + processedCommand.name] = [undefined, { name: processedCommand.name, description: processedCommand.description }]
+            command.addSubcommandGroup(processedCommand);
         };
         return command;
     };