title: How do I write sub-commands in my command?
body: <p>I wanted to put my "play", "stop", "skip", "leave" commands into one file called "music commands.js"
  so I put my "play" code in just like this:</p>
  
  <pre><code>const Discord = require('discord.js');
  const ytdl = require('ytdl-core');
  const bot = new Discord.Client();
  var servers = {};
  
  module.exports = {
      name: 'play',
      description: 'works',
      execute(msg, args) {
          function play(connection, msg) {
  
              var server = servers[msg.guild.id];
  
              server.dispatcher = connection.play(ytdl(server.queue[0], {
                  filter: "audioonly"
              }));
  
              server.queue.shift();
  
              server.dispatcher.on("end", function () {
                  if (server.queue[0]) {
                      play(connection, msg);
                  } else {
                      connection.disconnect();
                  }
              });
          }
  
          if (!args[1]) {
              msg.reply('please provide a link');
              return;
          }
          if (!msg.member.voice.channel) {
              msg.reply("Join a voice channel to play music!");
              return;
          }
  
          if (!servers[msg.guild.id]) servers[msg.guild.id] = {
              queue: []
          }
  
          var server = servers[msg.guild.id];
  
          server.queue.push(args[1]);
  
          const voiceChannel = msg.member.voice.channel;
          if (!voiceChannel) {
              return msg.reply('you are not in a voice channel.');
          } else {
              voiceChannel.join().then(function (connection) {
                  play(connection, msg);
              }).catch(err =&gt; console.error(err));
          }
      }
  
  }
  </code></pre>
  
  <p>(Note: if you have an idea to improve please post it)</p>
  
  <p>so I wanted to add my skip, stop and leave commands inside too while being able to access stuff like server.dispatcher at the same time since putting every command in it own file gave me some problem like connection is not defined but it's defined in the play command as paramter in the function so I used to use that 
  but putting everything on it own file it made a lot of things undefined 
  so if you can help in anyway please post a comment thanks!</p>