mirror of
https://github.com/MinazukiAmane/Tinasha-Bot.git
synced 2025-03-15 08:55:57 +08:00
feat: Node Check
- make sure check if the node connected before skipping - attempt to connect - add logging
This commit is contained in:
parent
6e69e76582
commit
cbfeef5eb8
@ -39,10 +39,23 @@ async function skip({ client, guildId }) {
|
||||
|
||||
const title = player.queue.current.info.title;
|
||||
|
||||
if (player.queue.tracks.length === 0) {
|
||||
return "There is no next song to skip to";
|
||||
// Check if the node is connected
|
||||
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();
|
||||
return `⏯️ ${title} was skipped`;
|
||||
// Proceed to skip the track
|
||||
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.";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user