Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord bot crashing after trying to play link(Node.js)

I am trying to make my bot work, yet again.

This is my play function.

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

and it does play.

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

I get my log that it's playing and after a few seconds or so I get an error message

TypeError: Cannot convert "null" to int

TypeError: Cannot convert "null" to int

and something here

discord-music-bot\node_modules\opusscript\build\opusscript_native_wasm.js:8 (TypeError: Cannot convert "null" to int)

Other scripts that are also mentioned in the discord.js documentation I can't install and I have tried everything I could think of.

like image 260
Vooyah Avatar asked Nov 07 '22 09:11

Vooyah


1 Answers

As sugessted on this github thread you should try using @discordjs/opus or node-opus instead of opusscript.

like image 53
Runner Avatar answered Nov 14 '22 22:11

Runner