This commit is contained in:
Loïc Bersier 2018-09-08 00:38:58 +02:00
parent f1fc195897
commit d9f33d3368

View file

@ -20,17 +20,16 @@ module.exports = class MusicCommand extends Command {
run(message, { ytblink }) { run(message, { ytblink }) {
const { voiceChannel } = message.member; const { voiceChannel } = message.member;
if (ytblink == 'stop') {
voiceChannel.leave()
} else
if (!voiceChannel) { if (!voiceChannel) {
return message.reply('please join a voice channel first!'); return message.reply('please join a voice channel first!');
} }
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);
if (ytblink == 'stop') {
voiceChannel.leave()
} else
dispatcher.on('end', () => voiceChannel.leave()); dispatcher.on('end', () => voiceChannel.leave());
}); });