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

703
Vistas
How to make my discord bot play audio in a voice channel using FFmpeg and discord.js v12?

I'm building a discord bot and when I try to make it play music in the voice channel, it just doesn't work. Is the dispatcher const and/or connection.play() part of some library? I'm currently using discord.js v12 and following their guide available here: https://v12.discordjs.guide/voice/

Note = I have @discordjs/opus installed, as well as FFmpeg, however, I don't require FFmpeg in my code and I don't know if I should. For that matter, I also don't see where I should use the opus library in my code.

The part that I get an error from my code is as follows:

pathMusic = musicTitle + '.mp3';

const dispatcher = connection.play(pathMusic);

dispatcher.on('start', () => {
    console.log(musicurl + ' is now playing!');
    msg.channel.send('Now playing: ' + musicTitle);
});

dispatcher.on('finish', () => {
    console.log(musicTitle + ' has finished playing!');
});

dispatcher.on('error', console.error);

msg.channel.send('Now playing: ' + musicTitle);

Any help would be deeply appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming you want to play music from youtube, you're missing 2 dependencies:

  • yt-search
  • ytdl-core

And for the discord/opus, I had an error when I tried to host it on Heroku, I think it's because the server is Linux based and it was needed for buffering(someone corrects me if I'm wrong)

about 4 years ago · Juan Pablo Isaza Denunciar
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