-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.js
33 lines (32 loc) · 947 Bytes
/
audio.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module.exports = (message, command) => {
const ytdl = require('ytdl-core');
if(command === "join"){
join(message);
return;
}
else if(command === "leave"){
if(message.member.voice.channel){
const channel = message.member.voice.channel.leave();
}
return;
}
else if(command === "play"){
join(message);
//const voiceChannel = message.member.voice.channel;
const connection = message.member.voice.channel.join();
const dispatcher = connection.play(ytdl('https://www.youtube.com/watch?v=vxKBHX9Datw'));
dispatcher.on('start', () => {
console.log('now playing');
});
dispatcher.on('finish', () => {
console.log('done');
});
}
}
async function join(message){
const voiceChannel = message.member.voice.channel;
if(!voiceChannel) return message.channel.send("you're not in a voice channel bih");
else {
const channel = message.member.voice.channel.join();
}
}