Reputation: 11
I just started learning javascript with node.js and I am attempting to create a music bot, I've set up the command handler and everything, however, I keep getting this error when I try to run the play command
Error: FFmpeg/avconv not found! at Function.getInfo (C:\Users\johnd\OneDrive\Desktop\discordBot\node_modules\prism-media\src\core\FFmpeg.js:130:11) at Function.create (C:\Users\johnd\OneDrive\Desktop\discordBot\node_modules\prism-media\src\core\FFmpeg.js:143:38) at new FFmpeg (C:\Users\johnd\OneDrive\Desktop\discordBot\node_modules\prism-media\src\core\FFmpeg.js:44:27) at AudioPlayer.playUnknown (C:\Users\johnd\OneDrive\Desktop\discordBot\node_modules\discord.js\src\client\voice\player\BasePlayer.js:47:20) at VoiceConnection.play (C:\Users\johnd\OneDrive\Desktop\discordBot\node_modules\discord.js\src\client\voice\util\PlayInterface.js:71:28) at C:\Users\johnd\OneDrive\Desktop\discordBot\commands\play.js:7:39 at processTicksAndRejections (internal/process/task_queues.js:97:5)
I'll post my play function below
async function playMusic(vc,songId) {
const stream = await ytdl(songId,{type: 'opus',filter : 'audioonly'});
vc.join().then(connection => {
const dispatcher = connection.play(stream,{volume: 1});
dispatcher.on('end', end => {
console.log("Song ended!");
vc.leave();
}).catch(err => console.log(err));
}).catch(err => console.log(err));
}
My proof of installation: https://i.sstatic.net/LRfJ4.jpg
Update 1: I'm still looking for others with this specific problem and can't find anything.
Upvotes: 0
Views: 6414
Reputation: 673
You need to run the following commands:
1) npm install ffmpeg-static
2) npm install @discordjs/opus
3) npm install ytdl-core
No need to install any binary or put it in the PATH, just install the above things like you installed discordjs. These things will show up in your package.json file after that. When you will host your bot in the cloud it will build it using the package.json.
Upvotes: 4
Reputation: 199
If his suggestion doesn't work try: run npm install FFmpeg-static and npm install @discordjs/opus
I was having the same issue and this is what worked
Upvotes: 0
Reputation: 1
have you added ffmpeg to the windows path yet?
here's a link to that, in case you haven't ===> https://www.youtube.com/watch?v=qjtmgCb8NcE
(be sure you have de .EXE on PATHEXT too)
ps.: I had the same problem, I restarted my computer and everything went to normal. And here's another link that could help https://www.npmjs.com/package/discord.js-music-v11
Upvotes: 0