Handle Subcommands in SubcommandGroups

Hello,

I'm working with SubcommandGroups atm and I'm trying to figure out how I can handle SubcommandGoups aswell.
The issue is that I'm loading my commands and Subcommands into collections as every bot tutorial tells you to.

Now I have client.slashCommands and client.subcommands as collections for my commands. Now, how do I properly manage subcommandgroups in there as well so that it's still clear to what subcommand they belong?

Does it make sense to store them as an object? Like
client.commands = {}
// Loading slash commands
fs.readdirSync("./slashCommands")
  .filter(file => file.endsWith(".js"))
  .forEach(file => {
    console.log(`Loading slash command ${file}...`);
    let pull = require(`./slashCommands/${file}`);
    client.commands[pull.name] = pull;
    console.log("Loaded!");
  });



// Loading subcommands
fs.readdirSync("./slashCommands/subCommands")
  .forEach(dir => {
    fs.readdirSync(`./slashCommands/subCommands/${dir}/`)
      .filter(file => file.endsWith(".js"))
      .forEach(file => {
        console.log(`Loading ${dir} subcommand ${file}...`);
        let pull = require(`./slashCommands/subCommands/${dir}/${file}`);
        client.commands[dir][pull.name] = pull;
        console.log("Loaded!");
      });
    });
Was this page helpful?