title: Discord Bot that Plays an Audio File When Someone Joins
body: <p>I would like the bot to join a voice channel when someone joins and then play a sound file.</p>
  
  <p>So far, I've gotten the bot to join the voice channel but it just doesn't play the sound and no errors show so I don't really know what is going wrong.</p>
  
  <pre><code>const Discord = require('discord.js');
  const bot = new Discord.Client();
  bot.login('BOT TOKEN');
  
  bot.on('voiceStateUpdate', (oldMember, newMember) =&gt; {
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel
    let textChannel = oldMember.guild.channels.get('TEXTCHANNEL ID')
  
    if(oldUserChannel === undefined &amp;&amp; newUserChannel !== undefined) {
  
      if (newMember.id === 'MEMEBER ID')         //Member 1
      {   
         newUserChannel.join()
         .then(connection =&gt; {
            console.log("Joined voice channel!");
            const dispatcher = connection.playFile("C:\Users\NAME\Documents\Welcome_Bot\music\bossman.mp3");
  
            dispatcher.on("end", end =&gt; {newUserChannel.leave()});
         })
          .catch(console.error);
  
      }
        else if (newMember.id === 'MEMEBER ID')       //Member 2
        {
         textChannel.send('Hello Member 2')
        }
          else if (newMember.id === 'MEMEBER ID')      //Member 3
          {
            textChannel.send('Hello Member 3')
          }
             else                                      //Random
             {
               textChannel.send("Hello") 
             } 
    } 
  });
  </code></pre>