Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda