im trying to make a leave command for my bot and im trying to make it so if the person using the command is not in the same voice channel as the bot it will respond and tell them they have to be in the same voice channel and if they are it will leave
i have this so far but i cant figure out how to get just the id for the channel the bot and and user are in to compare them
let userVoiceChannel = message.member.voice.connection;
let crashbotVoiceChannel = Crashbot.voice.connections;
return all the info about the channels the bot and the user are in i just cant figure out how to pick out just the id's using that to compare those
Crashbot.on('message', async message =>{
//creates an array called args and removes the first amount of charactors equal to the length of the prefix variable
let args = message.content.substring(PREFIX.length).split(" ");
let userVoiceChannel = message.member.voice.connection;
let crashbotVoiceChannel = Crashbot.voice.connections;
console.log(userVoiceChannel[0])
console.log(crashbotVoiceChannel)
//the switch equals true if the first word after the prefix is "leave"
switch (args[0]) {
case 'leave':
if (userVoiceChannel === null) return; message.reply("You must be a voice channel to use this command");
//if the message author is not in the same voice channel as the bot the bot replies and tells them that that have to be in the same channel to use that command
if (userVoiceChannel !== crashbotVoiceChannel) {
message.reply("You must be in the same channel as me to use this command");
return;
}
//if the message author is in the same voice channel as the bot it leaves the channel it is in
else if (userVoiceChannel === crashbotVoiceChannel) {
const connection = await message.member.voice.channel.leave();
message.channel.send("Successfully left the voice channel");
}
break;
}
});