Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda