erela.js icon indicating copy to clipboard operation
erela.js copied to clipboard

Init bug

Open qtAmyVT opened this issue 1 year ago • 1 comments

Hi there, my bot were successfully connected to the lavalink server, but when I try to play a song it would say: RangeError: No available nodes.

However, when I restart the main bot it would connect successfully: [WS => Lavalink 192.168.0.25] Node 192.168.0.25 connected successfully without any errors.

Lavalink logs: (during when the bot did restart and connected to lavalink)

2022-08-15 03:27:54.652  INFO 15477 --- [ XNIO-1 task-25] lavalink.server.io.SocketServer          : Connection successfully established from erela.js
2022-08-15 03:28:03.401  INFO 15477 --- [ XNIO-1 task-26] l.server.io.HandshakeInterceptorImpl     : Incoming connection from /192.168.0.25:46950
2022-08-15 03:28:03.412  INFO 15477 --- [ XNIO-1 task-26] lavalink.server.io.SocketServer          : Connection successfully established from erela.js```

qtAmyVT avatar Aug 15 '22 07:08 qtAmyVT

I was able to fix this issue by manually executing the initialization code, however the init doesn't run on start. It supposed to init on start but it doesn't, could be a bug.

qtAmyVT avatar Aug 15 '22 09:08 qtAmyVT

The docs clearly says about init the client, is this issue relevant?

// Ready event fires when the Discord.JS client is ready.
// Use EventEmitter#once() so it only fires once.
client.once("ready", () => {
  console.log("I am ready!");
  // Initiate the manager.
  client.manager.init(client.user.id);
});

anishshobithps avatar Aug 17 '22 14:08 anishshobithps

The docs clearly says about init the client, is this issue relevant?

// Ready event fires when the Discord.JS client is ready.
// Use EventEmitter#once() so it only fires once.
client.once("ready", () => {
  console.log("I am ready!");
  // Initiate the manager.
  client.manager.init(client.user.id);
});

Yes, I have that last line of the code added into the ready event file, but the initialization will never happens and I have to manually initialize to load the lavalink servers successfully.

qtAmyVT avatar Aug 30 '22 22:08 qtAmyVT

Are you listening to the nodeError and nodeDisconnect events aswell?

Spiderjockey02 avatar Sep 10 '22 12:09 Spiderjockey02

Yes, but nothing happens.

qtAmyVT avatar Sep 14 '22 18:09 qtAmyVT

Hey there, for whatever reason when I try to do console.log(client.shard.broadcastEval((client) => client.manager.init(client.user.id))); that fixes mostly my issue. For whatever reason something broke in erela.js in how the library handles shards. Either way this is a weird bug.

qtAmyVT avatar Oct 01 '22 00:10 qtAmyVT

No where in this repository does erela do anything with sharding, it only requires you to provide gateway voice updates and a method for sending gateway commands

You are responsible for everything else.

viztea avatar Oct 01 '22 00:10 viztea

Okay thank you. Seems like adding client.shard.broadcastEval((client) => client.manager.init(client.user.id)); to code will make the bot work.

qtAmyVT avatar Oct 02 '22 04:10 qtAmyVT