discord.js leave voice channel 1

discord.js leave voice channel

if(!message.guild.me.voice.channel) return message.channel.send("I'm not in a voice channel"); //If the bot is not in a voice channel, then return a message
message.guild.me.voice.channel.leave(); //Leave the voice channel

Here is what the above code is Doing:
1. First, we check if the user is in a voice channel. If they are not, then we return a message.
2. If the user is in a voice channel, then we check if the bot is in a voice channel. If the bot is not in a voice channel, then we return a message.
3. If the bot is in a voice channel, then we make the bot leave the voice channel.

Similar Posts