Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Node Connection Query #116

Open
arpanr opened this issue Jun 3, 2021 · 2 comments
Open

Node Connection Query #116

arpanr opened this issue Jun 3, 2021 · 2 comments

Comments

@arpanr
Copy link

arpanr commented Jun 3, 2021

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

@Tomato6966
Copy link

if(player && player.node && !player.node.connected) await player.node.connect()

@rilysh
Copy link

rilysh commented Apr 7, 2022

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants