interaction.guild.members.me.voice.channel gives null response?
Tried grabbing the voice channel ID from where the bot was at, and I keep getting null or it won't change when the bot joins a new vc.
const { SlashCommandBuilder } = require('discord.js');
const { getVoiceConnection } = require('@discordjs/voice')
module.exports = {
data: new SlashCommandBuilder()
.setName('leave')
.setDescription('Get the discord bot to leave the vc it is currently in <>_<>'),
async execute(interaction) {
let connection = getVoiceConnection(interaction.guild.id);
if (connection === undefined) {
await interaction.reply("I am not in a vc!");
return;
};
const channel = interaction.guild.members.me.voice.channel
await interaction.reply({content: `Successfully left ${channel}`});
return connection.destroy()
},
};