title: DiscordJs Event Handler With SubFolders And Aliases
body: <p>I have the following code which i have from a tutorial. I would like to extend it so  there are subfolders (instead of just one command folder) and aliases if the user knows a different and shorter name for the command.</p>
  
  <p>I added aliases and modules line, but am not sure how to implement those in in code that i have.</p>
  
  <pre><code>const fs = require('fs');
  const Discord = require('discord.js');
  const { prefix } = require('./config.json');
  const modules = ["administration", "fun", "misc", "information"];
  
  const client = new Discord.Client();
  client.commands = new Discord.Collection();
  client.aliases = new Discord.Collection();
  
  const commandFiles = fs.readdirSync('./commands').filter(file =&gt; file.endsWith('.js'));
  
  for (const file of commandFiles) {
      const command = require(`./commands/${file}`);
      client.commands.set(command.name, command);
  }
  
  client.once('ready', () =&gt; {
      console.log('Philomena is ready for action!');
    client.user.setActivity("`ph.help`")
    .then(console.log)
    .catch(console.error);
  });
  
  client.on('message', message =&gt; {
      if (!message.content.startsWith(prefix) || message.author.bot) return;
  
      const args = message.content.slice(prefix.length).split(/ +/);
      const command = args.shift().toLowerCase();
  
      if (!client.commands.has(command)) return;
  
      try {
          client.commands.get(command).execute(message, args);
      } catch (error) {
          console.error(error);
          message.reply('there was an error trying to execute that command!');
      }
  });
  
  
  client.login(process.env.BOT_TOKEN);
  </code></pre>