From d9f33d33681ce317402ede768df96803929d361e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Sat, 8 Sep 2018 00:38:58 +0200 Subject: [PATCH] --- commands/fun/music.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/commands/fun/music.js b/commands/fun/music.js index 0700af3f..8094bb37 100644 --- a/commands/fun/music.js +++ b/commands/fun/music.js @@ -20,17 +20,16 @@ module.exports = class MusicCommand extends Command { run(message, { ytblink }) { const { voiceChannel } = message.member; - if (ytblink == 'stop') { - voiceChannel.leave() - } else if (!voiceChannel) { return message.reply('please join a voice channel first!'); } - voiceChannel.join().then(connection => { const stream = ytdl(ytblink, { filter: 'audioonly' }); const dispatcher = connection.playStream(stream); + if (ytblink == 'stop') { + voiceChannel.leave() + } else dispatcher.on('end', () => voiceChannel.leave()); });