Finished Help, fixed command registration
diff --git a/src/utils/commandRegistration/register.ts b/src/utils/commandRegistration/register.ts
index 4290064..e146069 100644
--- a/src/utils/commandRegistration/register.ts
+++ b/src/utils/commandRegistration/register.ts
@@ -27,8 +27,8 @@
const last = i === files.length - 1 ? "└" : "├";
if (file.isDirectory()) {
console.log(`${last}─ ${colours.yellow}Loading subcommands of ${file.name}${colours.none}`)
- const fetched = (await import(`../../../${config.commandsFolder}/${file.name}/_meta.js`)).command;
- commands.push(fetched);
+ const fetched = (await import(`../../../${config.commandsFolder}/${file.name}/_meta.js`));
+ commands.push(fetched.command);
} else if (file.name.endsWith(".js")) {
console.log(`${last}─ ${colours.yellow}Loading command ${file.name}${colours.none}`)
const fetched = (await import(`../../../${config.commandsFolder}/${file.name}`));
@@ -171,6 +171,7 @@
const fullCommandName = "commands/" + commandName + (subcommandGroupName ? `/${subcommandGroupName}` : "") + (subcommandName ? `/${subcommandName}` : "");
+ console.log(fullCommandName, client.commands[fullCommandName])
const command = client.commands[fullCommandName]![0];
const callback = command?.callback;
const check = command?.check;
@@ -222,4 +223,5 @@
console.log(
(config.enableDevelopment ? `${colours.purple}Bot started in Development mode` :
`${colours.blue}Bot started in Production mode`) + colours.none)
+ console.log(client.commands)
};
diff --git a/src/utils/commandRegistration/slashCommandBuilder.ts b/src/utils/commandRegistration/slashCommandBuilder.ts
index a4474ac..72f92a2 100644
--- a/src/utils/commandRegistration/slashCommandBuilder.ts
+++ b/src/utils/commandRegistration/slashCommandBuilder.ts
@@ -1,4 +1,4 @@
-import type { SlashCommandSubcommandGroupBuilder } from "discord.js";
+import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from "discord.js";
import type { SlashCommandBuilder } from "discord.js";
import config from "../../config/main.json" assert { type: "json" };
import getSubcommandsInFolder from "./getFilesInFolder.js";
@@ -32,7 +32,9 @@
if (descriptionLocalizations) { subcommandGroup.setDescriptionLocalizations(descriptionLocalizations) }
for (const subcommand of fetched.subcommands) {
- subcommandGroup.addSubcommand(subcommand.command);
+ let processedCommand = subcommand.command(new SlashCommandSubcommandBuilder());
+ client.commands["commands/" + path + "/" + processedCommand.name] = [subcommand, { name: processedCommand.name, description: processedCommand.description }]
+ subcommandGroup.addSubcommand(processedCommand);
};
return subcommandGroup;
@@ -53,6 +55,8 @@
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({name: name, description: description})
+ client.commands[commandString!] = [undefined, { name: name, description: description }]
return (command: SlashCommandBuilder) => {
command.setName(name)
command.setDescription(description)
@@ -64,12 +68,11 @@
bitfield.add(userPermissions)
command.setDefaultMemberPermissions(bitfield.bitfield)
}
- client.commands[commandString!] = [undefined, { name: name, description: description }]
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;
}
@@ -77,8 +80,9 @@
command.addSubcommand(fetchedCommand);
}
for (const group of fetched.subcommandGroups) {
- command.addSubcommandGroup(group.command);
- client.commands[commandString! + "/" + group.command.name] = [undefined, { name: group.command.name, description: group.command.description }]
+ let processedCommand = group.command(new SlashCommandSubcommandGroupBuilder());
+ client.commands[commandString! + "/" + processedCommand.name] = [undefined, { name: processedCommand.name, description: processedCommand.description }]
+ command.addSubcommandGroup(processedCommand);
};
return command;
};
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 18bcd7b..43a0c8f 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -183,7 +183,7 @@
let component;
try {
component = await m.awaitMessageComponent({
- filter: (i) => i.user.id === this.interaction.user.id && i.channel!.id === this.interaction.channel!.id && i.id === m.id,
+ filter: (i) => i.user.id === this.interaction.user.id && i.channel!.id === this.interaction.channel!.id,
time: 300000
});
} catch (e) {
diff --git a/src/utils/getCommandDataByName.ts b/src/utils/getCommandDataByName.ts
index 0d4ac47..2d4deb7 100644
--- a/src/utils/getCommandDataByName.ts
+++ b/src/utils/getCommandDataByName.ts
@@ -18,6 +18,7 @@
const split = name.replaceAll(" ", "/")
const command = client.commands["commands/" + split]!;
+ console.log(command)
const mention = getCommandMentionByName(name);
return {
name: command[1].name,