Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Discord audio playing issue

Explanation

I have this code that plays youtube video audio in voice channels.

When it joins the channel I get an error that says "ffmpeg not found". I ran the terminal command "npm i ffmpeg-static" and it worked fine but after a couple of minutes I get a long error and the music stops playing.

This is my code:

client.on("ready", async () => {

  for (const channelId of Channels) {
    joinChannel(channelId);

    await new Promise(res => setTimeout(()=>res(2), 500))
  }
  
  function joinChannel(channelId) {
    client.channels.fetch(channelId).then(channel => {

      const VoiceConnection = joinVoiceChannel({
        channelId: channel.id,
        guildId: channel.guild.id,
        adapterCreator: channel.guild.voiceAdapterCreator
      });
      const resource = createAudioResource(ytdl("https://youtu.be/0J2gdL87fVs", {
          filter: "audioonly"
      }), {
        inlineVolume: true
      });
      resource.volume.setVolume(0.2);
      const player = createAudioPlayer()
      VoiceConnection.subscribe(player);
      player.play(resource);
      player.on("idle", () => {
        try {
          player.stop()
        }catch (e) {}
        try {
          VoiceConnection.destory()
        }catch (e) {}
        joinChannel(channelId)
      })
    }).catch(console.error)
  }
})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!