运行JavaScript代码时出错(Discord音乐bot)-OPUS_ENGINE_MISSING

时间:2018-06-21 09:17:12

标签: javascript discord discord.js

我试图运行一个简单的Discord机器人来播放音乐,该bot完美地连接到了频道,但是当它尝试播放音乐时,我发现了这个错误:

(node:3028) UnhandledPromiseRejectionWarning: Error: OPUS_ENGINE_MISSING

我的代码:

var servers = {};

function play(connection, message) {
    var server = servers[message.guild.id];

    server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: "audioonly"}));

    server.queue.shift();

    server.dispatch.on("end", function() {
        if(server.queue[0]) play(connection, message);
        else connection.disconnect();
    });
}

if(command === `${botSettings.prefix}play`)
{
    if(!args[0]) {
        message.channel.send("Please provide me a link!");
        return;
    }
    if(!message.member.voiceChannel) {
        message.channel.send("You must be in a voice channel!");
        return;
    }
    if(!servers[message.guild.id]) servers[message.guild.id] = {
        queue: []
    };

    var server = servers[message.guild.id];
    server.queue.push(args[0]);
    if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection) {
        play(connection, message);
    });
}

1 个答案:

答案 0 :(得分:0)

您可以这样安装opusscript

  

async:false

但是我听说不和谐者更喜欢node-opus

  

npm i opusscript

希望这会有所帮助