问题描述
我想让我的 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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!