I don't know how to make the user leave the voice channel.
I'm trying to make a verify thing, I have it all setup except for the leave voice channel part.
bot.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
var channel = bot.channels.get('614299678300831744');
if(oldUserChannel === undefined && newUserChannel !== 615306755420717143) {
channel.send(newMember + ' has been verified.');
let role = newMember.guild.roles.find(role => role.name === "Verified");
newMember.addRole(role);
let verifyEmbed = new Discord.RichEmbed()
.setAuthor("Verificaiton")
.setDescription("You have been verified")
.setFooter(newMember.guild.name)
.setColor("#98AFC7")
newMember.sendMessage(verifyEmbed);
newMember.disconnect();
}
});
I don't get any error, but it should disconnect me from the voice channel but can't?
Not sure if this is still relevant but since the update you can now do the following.
newMember.member.voice.disconnect();
Refer to the VoiceState class method disconnect
.