feat: Node Check

- make sure check if the node connected before skipping
- attempt to connect
- add logging
This commit is contained in:
Amane Serenetia 2025-02-21 07:09:53 +07:00
parent 6e69e76582
commit cbfeef5eb8

@ -39,10 +39,23 @@ async function skip({ client, guildId }) {
const title = player.queue.current.info.title; const title = player.queue.current.info.title;
if (player.queue.tracks.length === 0) { // Check if the node is connected
return "There is no next song to skip to"; const node = player.node;
if (!node || !node.connected) {
try {
await node.connect(); // Attempt to connect the node
} catch (error) {
console.error(`Failed to connect to Lavalink node: ${error.message}`);
return "🚫 Failed to connect to the music server. Please try again later.";
}
} }
await player.skip(); // Proceed to skip the track
return `⏯️ ${title} was skipped`; try {
await player.skip();
return `⏯️ ${title} was skipped`;
} catch (error) {
console.error(`Error while skipping track: ${error.message}`);
return "🚫 An error occurred while trying to skip the track.";
}
} }