title: Play discord command
body: <p>Hello I have been having a problem with a play command with discord. I am unsure of what the problem is and if it is possible please help. I will be honest I got this code from somewhere else but its for a private server. Please help fix this thank you. Anyway I have been trying to create a play, stop, skip, nowplaying command for ages and if this works it would be amazing thank you.</p>
  <p>Console Error:</p>
  <pre><code>TypeError: Cannot read property 'get' of undefined
  </code></pre>
  <p>Code:</p>
  <pre><code>const ytdl = require(&quot;ytdl-core&quot;);
  
  module.exports = {
    name: &quot;play&quot;,
    description: &quot;Play a song in your channel!&quot;,
    async execute(message) {
      try {
        const args = message.content.split(&quot; &quot;);
        const queue = message.client.queue;
        const serverQueue = message.client.queue.get(message.guild.id);
  
        const voiceChannel = message.member.voice.channel;
        if (!voiceChannel)
          return message.channel.send(
            &quot;You need to be in a voice channel to play music!&quot;
          );
        const permissions = voiceChannel.permissionsFor(message.client.user);
        if (!permissions.has(&quot;CONNECT&quot;) || !permissions.has(&quot;SPEAK&quot;)) {
          return message.channel.send(
            &quot;I need the permissions to join and speak in your voice channel!&quot;
          );
        }
  
        const songInfo = await ytdl.getInfo(args[1]);
        const song = {
          title: songInfo.videoDetails.title,
          url: songInfo.videoDetails.video_url
        };
  
        if (!serverQueue) {
          const queueContruct = {
            textChannel: message.channel,
            voiceChannel: voiceChannel,
            connection: null,
            songs: [],
            volume: 5,
            playing: true
          };
  
          queue.set(message.guild.id, queueContruct);
  
          queueContruct.songs.push(song);
  
          try {
            var connection = await voiceChannel.join();
            queueContruct.connection = connection;
            this.play(message, queueContruct.songs[0]);
          } catch (err) {
            console.log(err);
            queue.delete(message.guild.id);
            return message.channel.send(err);
          }
        } else {
          serverQueue.songs.push(song);
          return message.channel.send(
            `${song.title} has been added to the queue!`
          );
        }
      } catch (error) {
        console.log(error);
        message.channel.send(error.message);
      }
    },
  
    play(message, song) {
      const queue = message.client.queue;
      const guild = message.guild;
      const serverQueue = queue.get(message.guild.id);
  
      if (!song) {
        serverQueue.voiceChannel.leave();
        queue.delete(guild.id);
        return;
      }
  
      const dispatcher = serverQueue.connection
        .play(ytdl(song.url))
        .on(&quot;finish&quot;, () =&gt; {
          serverQueue.songs.shift();
          this.play(message, serverQueue.songs[0]);
        })
        .on(&quot;error&quot;, error =&gt; console.error(error));
      dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
      serverQueue.textChannel.send(`Start playing: **${song.title}**`);
    }
  };
  </code></pre>