問題描述
我想讓我的 Discord 機器人加入語音聊天,但每次我做到這一點時,我都會在 log(cmd) 中收到錯誤提示,FFMPEG not found
,請幫助我.
錯誤圖片:
這是代碼:
client.on('message', message => {//語音僅在公會中有效,如果消息不是來自公會,//我們忽略它如果(!message.guild)返回;if (message.content === '/join') {//僅當他們自己在一個時才嘗試加入發送者的語音頻道if (message.member.voiceChannel) {message.member.voiceChannel.join().then(connection => {//Connection 是 VoiceConnection 的一個實例message.reply('我已成功連接頻道!');}).catch(console.log);} 別的 {message.reply('您需要先加入語音頻道!');}}});
這是我的 package.json 文件:
<代碼>{名稱":xxxtentacion",版本":1.0.0",主":index.js",腳本":{開始":節點 index.js",開發":nodemon index.js"},依賴":{discord.js":^11.4.2","dotenv": "^6.2.0",ffmpeg":0.0.4",作品":0.0.6"},開發依賴":{nodemon":^1.18.9"}}
這將為您下載一個 Zip 存檔,您必須提取并復制 bin/
文件夾的所有內容,即 FFmpeg 二進制文件.或者,將它們存儲在 PATH 環境變量中列出的文件路徑中,以便在 shell 中簡單地作為 ffmpeg
運行.
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"
}
}
FFmpeg is a convenient tool to work with audio/video/image/subtitle stuff, in this context this tool is required for extracting audio from an arbitrary container for bitstream (eg. mp4, mkv, flv, ogg) to a discord compatible VoIP codec OPUS.
Though it's intended be platform independent but for each platform requires different procedures, Note that: I only listed those platforms with which I have expertise with.
GNU/Linux
You mostly use the package manager to install it along with its dependencies, or you can just use the way of manually compiling the code with the steps described at here.
# Ubuntu / Debian / Linux Mint
sudo apt install ffmpeg
# ArchLinux / Manjaro / Anarchy
sudo pacman -S ffmpeg
# Gentoo / Funtoo
USE=opus sudo emerge ffmpeg
Windows
Windows is not easy as GNU/Linux, you either manually satisfy all dependencies then compile all the stuff all by yourself with MSVC or use Cygwin or Msys2 to compile. An alternative way is to download pre-compiled windows binaries from Zeranoe's website. Due to Zeranoe's website is closed, download from Gyan's website or anywhere else.
This will download you a Zip archive which you've to extract and copy all contents of the bin/
folder, those are the FFmpeg binaries. Optionally, store them at a file path which is listed in the PATH environment variable, to run it simply as ffmpeg
in a shell.
這篇關于Discord bot:修復“找不到 FFMPEG"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!