Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
VoiceStates not updating discord.js

I'm trying to make a command to move all the members in a voice channel (the one the author of the command is in) to another (given in parameter). But I have a problem, the VoiceState won't update consistently, connecting and changing channel is ok but if disconnect from the voice channel the bot will still see my voiceState as if I were connected.

//The command file
const Discord= require('discord.js');
const {SlashCommandBuilder} = require("@discordjs/builders");
module.exports = {
    data: new SlashCommandBuilder()
        .setName('move')
        .setDescription('Move all the members to a specific voice channel')
        .addChannelOption(option =>
            option.setName('voicechannel')
                .setDescription('The voice channel to move everyone in')
                .setRequired(true)),
    async execute(interaction) {
        const author = interaction.member
        const voice = author.guild.voiceStates.cache
        console.log(voice.get(author.id))
        console.log(interaction.options.get('voicechannel').channel.id)
        if (voice.get(author.id) == undefined || voice.get(author.id) == null){
            await interaction.reply({content : 'You need to be in a voice channel first', ephemeral: true})
        } else if (interaction.options.get('voicechannel').channel.id == voice.get(author.id).channelId) {
            await  interaction.reply({content : 'Can\'t move to the same channel', ephemeral: true})
        } else {
            await interaction.reply({content : 'ok', ephemeral: true})
            ///TO IMPLEMENT CODE
        }
    },
};
//my client constructor
const client = new Discord.Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES] });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Make sure you have the GUILD_VOICE_STATES intent set upon Client construction.

const client: Client = new discord.Client({
    intents: 641,
});

I had a similar issue, where the state of the voice channels was set when the bot was started up, but would never update.

I used this intents calculator to easily contain all the intents.

Check out the 'music bot' preset in particular (641).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda