Haha-Yes/commands/fun/music.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-09-07 22:48:43 +02:00
const { Command } = require('discord.js-commando');
const ytdl = require('ytdl-core');
module.exports = class MusicCommand extends Command {
constructor(client) {
super(client, {
name: 'music',
group: 'fun',
memberName: 'music',
2018-09-08 23:09:33 +02:00
description: 'Play youtube link in vocal ( DOSENT WORK RN TRYING TO FIX IT )',
2018-09-07 22:48:43 +02:00
args: [
{
key: 'ytblink',
2018-09-08 16:45:27 +02:00
prompt: 'Wich Youtube link would you like to play?\nTo stop the bot just do "haha music stop"',
2018-09-07 22:48:43 +02:00
type: 'string',
}
]
});
}
run(message, { ytblink }) {
const { voiceChannel } = message.member;
2018-09-08 23:09:33 +02:00
2018-09-08 22:30:50 +02:00
if (!voiceChannel) {
return message.reply('please join a voice channel first!');
2018-09-08 23:09:33 +02:00
} else
2018-09-08 22:30:50 +02:00
if (ytblink == 'stop') {
voiceChannel.leave()
} else
voiceChannel.join().then(connection => {
const stream = ytdl(ytblink, { filter: 'audioonly' });
const dispatcher = connection.playStream(stream);
dispatcher.on('end', () => voiceChannel.leave());
});
2018-09-08 23:09:33 +02:00
2018-09-07 22:48:43 +02:00
}
2018-09-08 23:09:33 +02:00
}