“错误:找不到Opus引擎。”在尝试播放mp3文件时(discord.js)

时间:2018-04-29 07:07:46

标签: javascript discord.js

我正在使用Heroku来托管我的应用,我有以下代码:

if (isReady && message.content === '!play')
{
    isReady = false;
    var voiceChannel = message.member.voiceChannel;
    voiceChannel.join().then(connection =>
    {
        const dispatcher = connection.playFile('./BRODYQUEST.mp3');
        dispatcher.on("end", end => {
            voiceChannel.leave();
        });
    }).catch(err => console.log(err));
    isReady = true;
}

当我输入命令时,机器人加入我的频道,但它不播放任何音乐。我在控制台中收到此错误:

2018-04-29T07:00:49.053720+00:00 app[worker.1]: Error: Couldn't find an Opus engine.

2018-04-29T07:00:49.053738+00:00 app[worker.1]:     at Object.exports.guaranteeOpusEngine (/app/node_modules/discord.js/src/client/voice/opus/OpusEngineList.js:30:31)

2018-04-29T07:00:49.053739+00:00 app[worker.1]:     at AudioPlayer.playUnknownStream (/app/node_modules/discord.js/src/client/voice/player/AudioPlayer.js:87:18)

2018-04-29T07:00:49.053741+00:00 app[worker.1]:     at VoiceConnection.playFile (/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:448:24)

2018-04-29T07:00:49.053742+00:00 app[worker.1]:     at voiceChannel.join.then.connection (/app/bot.js:71:40)

2018-04-29T07:00:49.053744+00:00 app[worker.1]:     at <anonymous>

2018-04-29T07:00:49.053745+00:00 app[worker.1]:     at process._tickCallback (internal/process/next_tick.js:188:7)

2 个答案:

答案 0 :(得分:1)

要运行此程序,您需要安装ytdl-core

npm install --save ytdl-core

如果收到显示“ OPUS_ENGINE_MISSING”的错误,则需要安装discord.js建议的其中一个软件包。

npm install --save node-opus

如果出现“找不到FFMPEG”错误,则可以通过安装ffmpeg来解决。

在Debian / Ubuntu上:

sudo apt-get install ffmpeg

在Windows上:

npm install ffmpeg-binaries --save

另外,有报道称,无法从Windows 10提供的Ubuntu子系统中以这种方式播放音频。

答案 1 :(得分:0)

所以你已经成功安装了discord.js但是要解码和编码你想要播放的mp3文件,你必须安装一个编解码器来为你做这件事:

所以你只需安装npm install discord.js node-opus就可以了。