Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

700
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda