|
|
@ -31,12 +31,14 @@ module.exports = class MusicCommand extends Command {
|
|
|
|
// If user say "stop" make the bot leave voice channel
|
|
|
|
// If user say "stop" make the bot leave voice channel
|
|
|
|
if (ytblink == 'stop') {
|
|
|
|
if (ytblink == 'stop') {
|
|
|
|
voiceChannel.leave()
|
|
|
|
voiceChannel.leave()
|
|
|
|
|
|
|
|
message.say('I leaved the channel');
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
voiceChannel.join().then(connection => {
|
|
|
|
voiceChannel.join().then(connection => {
|
|
|
|
const stream = ytdl(ytblink, { filter: 'audioonly' });
|
|
|
|
const stream = ytdl(ytblink, { filter: 'audioonly' });
|
|
|
|
const dispatcher = connection.playStream(stream);
|
|
|
|
const dispatcher = connection.playStream(stream);
|
|
|
|
// End at then end of the audio stream
|
|
|
|
// End at then end of the audio stream
|
|
|
|
dispatcher.on('end', () => voiceChannel.leave());
|
|
|
|
dispatcher.on('end', () => voiceChannel.leave());
|
|
|
|
|
|
|
|
message.say('Music ended, Leaved the channel');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|