title: Is there any way to do subfolders in the handler command?
body: <p>I'm trying to make another command handler, more advanced. I have already seen several types of codes explaining the handler command with folders / sub-folders / command but I still do not quite understand how to make that.</p>
  
  <p>I already tried using fs, and I wanted to use it to do this, but I still could not.</p>
  
  <p>This is my current code (without the attempts).</p>
  
  <pre class="lang-js prettyprint-override"><code>const Discord = require("discord.js");
  const client = new Discord.Client();
  const db = require('quick.db');
  const fs = require("fs");
  client.commands = new Discord.Collection();
  client.aliases = new Discord.Collection();
  client.events = new Discord.Collection();
  
  const utils = require("./utils/utils");
  const config = require("./utils/config.json");
  
  fs.readdir("./src/events/", (err, files) =&gt; {
      if (err) return console.error(err);
      files.forEach(file =&gt; {
          let eventFunction = require(`./src/events/${file}`);
          let eventStart = eventFunction.run.bind(null, client);
          let eventName = file.split(".")[0];
          client.events.set(eventName, eventStart);
          client.on(eventName, (...args) =&gt; eventFunction.run(client, utils, ...args));
      });
  });
  
  fs.readdir('./src/commands/', (err, files) =&gt; {
      if (err) console.error(err);
      files.forEach(f =&gt; {
          let props = require(`./src/commands/${ f }`);
          props.fileName = f;
          client.commands.set(props.help.name, props);
          props.help.aliases.forEach(alias =&gt; {
              client.aliases.set(alias, props.help.name);
          });
      });
  });
  
  client.on("message", async message =&gt; {
      try {
          let prefix = await db.fetch(`prefixo_${message.guild.id}`);
  
          if (prefix === null) prefix = "m!";
          if (message.author.bot) return;
          if (message.content.indexOf(prefix) !== 0) return;
  
          const args = message.content.slice(prefix.length).trim().split(/ +/g);
          let command = args.shift().toLowerCase();
  
          if (client.aliases.has(command)) command = client.commands.get(client.aliases.get(command)).help.name;
  
          if (client.commands.get(command).config.restricted == true) {
              if (message.author.id !== config.ownerID) return utils.errorEmbed(message, 'No permission.');
          }
  
          if (client.commands.get(command).config.args == true) {
              if (!args[0]) return utils.errorEmbed(message, `Invalid arguments. Use: ${prefix + 'help ' + client.commands.get(command).help.name}`);
          }
  
          let commandFile = require(`./src/commands/${command}.js`);
          commandFile.run(client, message, args, utils);
  
      } catch (err) {
          if (err.message === `Cannot read property 'config' of undefined`) return;
          if (err.code == "MODULE_NOT_FOUND") return;
      console.error(err);
      }
  });
  
  client.login(config.token);
  </code></pre>