Discord bot 在尝试播放链接后崩溃(Node.js)

Voj*_*vic 5 javascript node.js opus discord discord.js

我正在尝试让我的机器人再次工作。

这是我的播放功能。

function play(connection, message) {
        var server = servers[message.guild.id];
        server.dispatcher = connection.play(
          ytdl(server.queue[0], { filter: "audioonly" })
        );
        server.queue.shift();

        server.dispatcher.on("end", function() {
          if (server.queue[0]) {
            play(connection, message);
          } else {
            connection.disconnect();
          }
        });
      }
Run Code Online (Sandbox Code Playgroud)

它确实会播放。

if (!message.guild.voiceConnection)
        message.member.voice.channel.join().then(function(connection) {
          message.channel.send("Playing tune now, Enjoy!");
          play(connection, message);
          console.log("Playing tune now!");
        });
Run Code Online (Sandbox Code Playgroud)

我得到我的日志,它正在播放,几秒钟后我收到一条错误消息

类型错误:无法将“null”转换为 int

类型错误:无法将“null”转换为 int

和这里的东西

discord-music-bot\node_modules\opusscript\build\opusscript_native_wasm.js:8(类型错误:无法将“null”转换为int)

在 discord.js 文档中也提到的其他脚本我无法安装,我已经尝试了所有我能想到的。

小智 1

正如此github 线程上所建议的,您应该尝试使用@discordjs/opusornode-opus代替opusscript.