我试图运行一个简单的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);
});
}