added comment

This commit is contained in:
Loic Bersier 2018-09-11 15:57:32 +02:00
parent c4331ef249
commit c47c95eaf6

View file

@ -20,11 +20,12 @@ module.exports = class MusicCommand extends Command {
async run(message, { ytblink }) { async run(message, { ytblink }) {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
// If not in voice channel ask user to join
if (!voiceChannel) { if (!voiceChannel) {
return message.reply('please join a voice channel first!'); return message.reply('please join a voice channel first!');
} else } else
// If user say "stop" make the bot leave voice channel
if (ytblink == 'stop') { if (ytblink == 'stop') {
voiceChannel.leave() voiceChannel.leave()
} else } else
@ -32,7 +33,7 @@ module.exports = class MusicCommand extends Command {
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
dispatcher.on('end', () => voiceChannel.leave()); dispatcher.on('end', () => voiceChannel.leave());
}); });