Reputation: 65
Whenever I use the skip command on the last song of the queue, it skips the song but the bot will crash showing this error in the terminal (CMD). Here is the code:
else if (cmd === "skip") {
let queue = distube.getQueue(message.guild.id);
let channel = message.member.voice.channel;
if (!channel) {
return message.channel.send(`** You need to Join Voice Channel **`)
}
if (!queue) {
return message.channel.send(`** Nothing Playing **`)
}
queue.skip();}
Upvotes: 0
Views: 447
Reputation: 65
I found out the answer by myself. Here is to anyone who needs it
else if (cmd === "skip") {
let queue = distube.getQueue(message.guild.id);
let channel = message.member.voice.channel;
if (!channel) {
return message.channel.send(`** You need to Join Voice Channel **`)
}
if (!queue) {
return message.channel.send(`** Nothing Playing **`)
}
if (queue.autoplay || queue.songs.length > 1) distube.skip(message)
else distube.stop(message) }
Basically the code is the same but I added an if statement in the end. What it does is that the bot checks wether autoplay is enabled or the amount of songs in queue is more than one. Then it will skip if either of those are true. If it is not the bot will stop the queue and leave the voice channel if you have leaveOnStop enabled in options.
Upvotes: 0