问题
I want to make my Discord bot join voice chat but every time I make it I get a error into log(cmd) saying, FFMPEG not found, please help me.
Picture of the error:
This is the code:
client.on('message', message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;
if (message.content === '/join') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voiceChannel) {
message.member.voiceChannel.join()
.then(connection => { // Connection is an instance of VoiceConnection
message.reply('I have successfully connected to the channel!');
})
.catch(console.log);
} else {
message.reply('You need to join a voice channel first!');
}
}
});
this is my package.json file:
{
"name": "xxxtentacion",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"dependencies": {
"discord.js": "^11.4.2",
"dotenv": "^6.2.0",
"ffmpeg": "0.0.4",
"opusscript": "0.0.6"
},
"devDependencies": {
"nodemon": "^1.18.9"
}
}
回答1:
Introduction to Voice Voice in discord.js can be used for many things, such as music bots, recording or relaying audio.
In discord.js, you can use voice by connecting to a VoiceChannel to obtain a VoiceConnection, where you can start streaming and receiving audio.
To get started, make sure you have:
FFmpeg - npm install ffmpeg-binaries
an opus encoder, choose one from below:
npm install node-opus(better performance)npm install opusscript(a good network connection)
The preferred opus engine is node-opus, as it performs significantly better than opusscript. When both are available, discord.js will automatically choose node-opus. Using opusscript is only recommended for development environments where node-opus is tough to get working. For production bots, using node-opus should be considered a necessity, especially if they're going to be running on multiple servers.
回答2:
FFmpeg is cross-platform audio/video transcoder. This is needed for trans-coding any type audio/video stream to a compatible VoIP audio format (opus).
Installation
FFmpeg is cross-platform but the installation process is platform dependent. So here are the popular methods to install in (Linux, Windows).
Linux
# go into terminal and install this
sudo apt install 'ffmpeg'
Windows
Download the static binaries from Zeranoe's website.
Extract the archive file and copy the contents of the bin folder and copy them to C:\Windows\System32 or in any folder of your choice.
But, make sure that the folder is in the PATH.
来源:https://stackoverflow.com/questions/54658125/discord-bot-fix-ffmpeg-not-found