|
|
|
@ -20,11 +20,12 @@ module.exports = class MusicCommand extends Command {
|
|
|
|
|
async run(message, { ytblink }) {
|
|
|
|
|
const { voiceChannel } = message.member;
|
|
|
|
|
|
|
|
|
|
// If not in voice channel ask user to join
|
|
|
|
|
if (!voiceChannel) {
|
|
|
|
|
return message.reply('please join a voice channel first!');
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
|
|
// If user say "stop" make the bot leave voice channel
|
|
|
|
|
if (ytblink == 'stop') {
|
|
|
|
|
voiceChannel.leave()
|
|
|
|
|
} else
|
|
|
|
@ -32,7 +33,7 @@ module.exports = class MusicCommand extends Command {
|
|
|
|
|
const stream = ytdl(ytblink, { filter: 'audioonly' });
|
|
|
|
|
const dispatcher = connection.playStream(stream);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// End at then end of the audio stream
|
|
|
|
|
dispatcher.on('end', () => voiceChannel.leave());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|