erela.js
erela.js copied to clipboard
Init bug
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```
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.
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);
});
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.
Are you listening to the nodeError and nodeDisconnect events aswell?
Yes, but nothing happens.
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.
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.
Okay thank you. Seems like adding client.shard.broadcastEval((client) => client.manager.init(client.user.id));
to code will make the bot work.