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

207
Visualizações
How can I check if someone is in a voice channel in DiscordJS V13?

I'm trying to check if the user who initiated a command is currently in a voice channel, and while after I run the bot my code works and I get the voice channel information back if I then LEAVE the channel and re-initiate the command I'm getting back the same voice channel information like it was cached? The only way to receive up-to-date information is to restart my bot entirely.

export const interactionListener = async (interaction, client) => {
  if (!interaction.isCommand()) return; 
  const { commandName } = interaction; 
  switch (commandName) {
    case 'play':
      let user = await interaction.member.fetch();
      let channel = await user.voice.channel;
      if (!channel) {
        interaction.reply('you are not in a voice channel');
      } else {
        interaction.channel.send('do something else');
      }
 }
};

and that code is running on an interactionCreate here

client.on('interactionCreate', async (interaction) => {
  interactionListener(interaction, client);
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

FIXED: I needed another intent

Previous intents were:

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MEMBERS,
    Intents.FLAGS.GUILD_PRESENCES,
  ],
});

NEW Intents are:

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MEMBERS,
    Intents.FLAGS.GUILD_PRESENCES,
    Intents.FLAGS.GUILD_VOICE_STATES,
  ],
});

I was missing

Intents.FLAGS.GUILD_VOICE_STATES
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