i recently started to code a discord bot with javascript. However i am currently stuck at the moment. I am trying to check if the user is already in a voice channel. after that i want to check if my bot is alrady in the voice channel if not, he needs to join.
My code break on mutliple levels.
The code where it checks if the user is connected to a voice channel does not seem to work, i am in a voice channel it triggers the code anyway.
if(!args[1]){
msg.channel.send("you need to provide a link")
return;
}
I keep getting the join() is not a func but i am pretty sure it is, but somehow it does not work.
function play(connection, msg){
var server = servers[msg.guild.id]
server.dispatcher = connection.playStream(ytdl(server.queue[0], { filter: "audioonly" }))
server.queue.shift()
server.dispatcher.on("end", function(){
if(server.queue[0]){
play(connection, msg)
} else {
connection.disconnect()
}
})
}