My code:
// not very relevant stuff
const {
SlashCommandBuilder
} = require('@discordjs/builders');
const {
MessageEmbed
} = require('discord.js');
const tip = require('../../tips/randomtip')
const fs = require('fs')
{
const status = require('./status')
if(status.inUsed = true){
status.inUsed = false
fs.writeFileSync( './commands/music/status.json', JSON.stringify(status,null,2))
}
}
// very relevant stuff
module.exports = {
data: new SlashCommandBuilder()
.setName('join')
.setDescription('Join the voice channel you are in'),
async execute(interaction) {
const voice = interaction.member.voice
// console.log(voice)
console.log(voice.channel)
},
};
Problem is voice.channel remains the same (I didn’t check if they are exactly the same, but the channel name and channel is are the same, cuz that what matters)
I’m using discord.js v13 latest version so don’t even question me
If the problem you are having is that the member.voice variable does not update after the bot first starts up, the solution could be to add the GUILD_VOICE_STATES intent upon Client construction.
Here is an example of how you could do this:
const client = new Client ({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES] });
Adding intents.FLAGS.GUILD_VOICE_STATES should make member.voice update correctly when the user changes voice channel.