【问题标题】:Discord bot crashing after trying to play link(Node.js)Discord bot 在尝试播放链接后崩溃(Node.js)
【发布时间】:2020-06-26 19:12:34
【问题描述】:

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

这是我的播放功能。

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();
          }
        });
      }

它确实会播放。

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!");
        });

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

TypeError: 无法将“null”转换为 int

TypeError: 无法将“null”转换为 int

这里有一些东西

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

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

【问题讨论】:

  • 您是否尝试在 Node.js 中播放 Ogg Opus 文件?

标签: javascript node.js discord discord.js opus


【解决方案1】:

按照github thread 的建议,您应该尝试使用@discordjs/opusnode-opus 而不是opusscript

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-12
    • 1970-01-01
    • 2020-09-19
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多