我想让我的 Discord 机器人加入语音聊天,但每次我这样做时,我都会在 log(cmd) 中收到错误消息:FFMPEG not found
, 请帮我。
错误图片:
这是代码:
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!');
}
}
});
这是我的 package.json 文件:
{
"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"
}
}
语音简介Discord.js 中的语音可用于许多用途,例如音乐机器人、录制或转发音频。
在discord.js中,您可以通过连接到VoiceChannel来获取VoiceConnection来使用语音,您可以在其中开始流式传输和接收音频。
首先,请确保您拥有:
FFmpeg -npm install ffmpeg-binaries
opus 编码器,从下面选择一个:
-
npm install node-opus
(更好的性能)
-
npm install opusscript
(良好的网络连接)
首选的 opus 引擎是 node-opus,因为它的性能明显优于 opusscript。当两者都可用时,discord.js 将自动选择 node-opus。仅建议在 Node-opus 难以运行的开发环境中使用 opusscript。对于生产机器人,使用 node-opus 应该被认为是必要的,特别是当它们要在多个服务器上运行时。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)