erela.js
erela.js copied to clipboard
Node Connection Query
Hi
If Manager is not connected to any node, player.create() throws "No available nodes." which is cool, but is there a way to catch this and try to connect to nodes, like init() again once before telling the server users that music nodes are down?
Thanks
if(player && player.node && !player.node.connected) await player.node.connect()
Hi
If Manager is not connected to any node, or player.create() throws "No available nodes." which is cool, but is there a way to catch this and try to connect to nodes, like init() again once before telling the server users that music nodes are down?
Thanks
try...catch can handle throw exceptions.
try {
<Player>.create(...);
} catch {
console.log("Not connected.");
}
Using something like <Player>.connect() can cause the same issue, and if a lavalink server is not running or having issues while connecting, this trick won't going to work. You better wait until it connects to the node.
Or if you want explicitly handle this error, use nodejs build-in process API, process.on(..., (f) => cb(f));
https://nodejs.org/api/process.html