Reputation: 61
I have a problem I am using discord.js to play music but my bot does not leave the voice channel when I send a command $stop, Please help!
case 'stop':
var server = servers[message.guild.id];
if(message.guild.voiceConnection){
for(var i = server.queue.length -1; i<=0; i--){
server.queue.splice(i, 1);
}
server.dispatcher.end();
client.leaveVoiceChannel(message.member.voiceState.channelID);
message.channel.send('Leaving the channel!')
}
if(message.guild.connection) message.guild.voiceConnection.disconnect();
break;
Upvotes: 1
Views: 270
Reputation: 61
I found a solution:- use
message.member.voice.channel.leave();
Upvotes: 1