【问题标题】:"Error: Couldn't find an Opus engine." when trying to play an mp3 file (discord.js)“错误:找不到 Opus 引擎。”尝试播放 mp3 文件时 (discord.js)
【发布时间】:2019-09-06 23:03:26
【问题描述】:

我正在使用 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)

【问题讨论】:

  • 欢迎来到 Stack Overflow!我已在您的问题中包含错误并更新了您的标题,以便其他人立即看到它的含义。我还更改了您的一些句子结构并删除了一些绒毛,以使问题更清楚。如果您对这些修改不满意,请随时再次修改您的问题!
  • 我可以看看你的 GitHub 的 package.json 吗?

标签: javascript discord.js


【解决方案1】:

要运行它,您需要安装 ytdl-core

npm install --save ytdl-core

如果您收到“OPUS_ENGINE_MISSING”错误消息,则需要安装 discord.js 推荐的 opus 软件包之一。

npm install --save node-opus

如果您收到“找不到 FFMPEG”的错误消息,可以通过安装 ffmpeg 来解决。

在 Debian / Ubuntu 上:

sudo apt-get install ffmpeg

在 Windows 上:

npm install ffmpeg-binaries --save

此外,有报道称在 Windows 10 提供的 Ubuntu 子系统中以这种方式播放音频不起作用。

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

    • 我如何在 heroku 上做到这一点。我使用 heroku 来托管我的机器人。 (和 GitHub)
    • 你应该登录到你的服务器,然后输入我上面写的命令。
    • 它说 heruko 有 node.js 所以你应该能够做到这一点。
    • 它说你应该首先重建node-gyp。只需输入:node-gyp rebuild
    猜你喜欢
    • 2021-07-24
    • 1970-01-01
    • 2013-02-04
    • 2020-09-04
    • 2021-01-15
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多