added comment
This commit is contained in:
parent
c4331ef249
commit
c47c95eaf6
1 changed files with 3 additions and 2 deletions
|
@ -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());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue