title: error connection.play is not a function in discordjs v13
body: <p>i was trying to create a bot and I was trying to do from a youtube tutorial and I think its because I'm using discord.js v13 so if anyone can tell me how to downgrade to a lower discord.js version that could also be a solution but if someone knows how to solve this problem then please review my code and help me. the versions of the dependencies I'm using are-</p>
  <pre><code>&quot;@discordjs/opus&quot;: &quot;^0.6.0&quot;,
  &quot;@discordjs/voice&quot;: &quot;^0.6.0&quot;,
  &quot;@types/ws&quot;: &quot;^7.4.7&quot;,
  &quot;discord-api-types&quot;: &quot;^0.22.0&quot;,
  &quot;discord.js&quot;: &quot;^13.1.0&quot;,
  &quot;ffmpeg&quot;: &quot;^0.0.4&quot;,
  &quot;ffmpeg-static&quot;: &quot;^4.4.0&quot;,
  &quot;tiny-typed-emitter&quot;: &quot;^2.1.0&quot;,
  &quot;yt-search&quot;: &quot;^2.10.1&quot;,
  &quot;ytdl-core&quot;: &quot;^4.9.1&quot;
  </code></pre>
  <p>keep getting this message -</p>
  <p>the code in index.js=</p>
  <pre class="lang-js prettyprint-override"><code>const Discord = require(&quot;discord.js&quot;);
     const fs = require(&quot;fs&quot;);
     const config = require(&quot;./config.json&quot;);
  
  const intents = new Discord.Intents(32767);
  
  const client = new Discord.Client({ intents });
  
  const prefix = &quot;-&quot;;
  
  client.on(&quot;ready&quot;, () =&gt; {
    console.log(&quot;client is ready&quot;);
  });
  client.commands = new Discord.Collection();
  // const commandFiles = fs
  //   .readdirSync(&quot;./commands/&quot;)
  //   .filter((file) =&gt; file.endsWith(`.js`));
  // for (const file of commandFiles) {
  //   const command = require(`./commands/${file}`);
  //   client.commands.set(command.name, command);
  // }
  // client.commands.get(command).execute(client, message, args, command, Discord);
  
  const commandFiles = fs
    .readdirSync(&quot;./commands/&quot;)
    .filter((file) =&gt; file.endsWith(&quot;.js&quot;));
  for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    console.log(file);
    console.log(command);
    client.commands.set(command.name, command);
  }
  
  client.on(&quot;messageCreate&quot;, (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 (command === &quot;hello&quot;) {
      message.channel.send(&quot;hey there chutiyon&quot;);
    } else if (command === &quot;ping&quot;) {
      client.commands.get(&quot;ping&quot;).execute(message, args);
    } else if (command === &quot;play&quot;) {
      console.log(client.commands);
      client.commands.get(&quot;play&quot;).execute(message, args);
    } else if (command === &quot;leave&quot;) {
      client.commands.get(&quot;leave&quot;).execute(message, args);
    }
  });
  
  client.login(config.token);
  </code></pre>
  <p>the code in play.js=</p>
  <pre><code>const ytSearch = require(&quot;yt-search&quot;);
  const { joinVoiceChannel } = require(&quot;@discordjs/voice&quot;);
  module.exports = {
    name: &quot;play&quot;,
    description: &quot;this is play command&quot;,
    async execute(message, args) {
      // const voiceChannel = message.member.voice.channel;
      console.log(message);
      console.log(args);
      const connection = joinVoiceChannel({
        channelId: message.member.voice.channel.id,
        guildId: message.guild.id,
        adapterCreator: message.guild.voiceAdapterCreator,
      });
      // await voiceChannel.join();
      const VideoFinder = async (query) =&gt; {
        const videoResult = await ytSearch(query);
        return videoResult.videos.length &gt; 1 ? videoResult.videos[0] : null;
      };
      console.log(VideoFinder);
      const video = await VideoFinder(args.join(&quot;&quot;));
      console.log(video);
      if (video) {
        const stream = ytdl(video.url, { filter: &quot;audioonly&quot; });
        console.log(&quot;---------------------------------------&quot;);
        console.log(stream);
        console.log(typeof connection.play);
        await connection
          .play(stream, { seek: 0, volume: 1, type: &quot;opus&quot; })
          .on(finish, () =&gt; {
            voiceChannel.leave();
          });
        await message.reply(`:thumbsup: nowplaying ----${video.title}---`);
      } else {
        message.channel.send(&quot;video not found&quot;);
      }
    },
  };
  </code></pre>
  <pre><code>
  .play(stream, { seek: 0, volume: 1, type: &quot;opus&quot; })
           ^
  
  TypeError: connection.play is not a function
      at Object.execute (C:\Users\pc\WE_SOO_NOOBLA_BOT\commands\play.js:30:10)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
  </code></pre>