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

284
Vistas
Fetching Discord Channel Members

I am attempting to fetch all the members of a certain Discord voice channel using discord.js

I have a function trying to do this right now. It takes in an interaction, that is given when a user runs a slash command on Discord. The options parameter is simply the channel they pass in to the command.

This is what running the command looks like

const execute = async (interaction, options) => {
  if (interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
    await interaction.guild.members.fetch();
    await interaction.deferReply({ ephemeral: true });
    const channelInput = options.getChannel('channel');
    const channel = await interaction.member.guild.channels.fetch(channelInput.id);
    const members = channel.members.map(member => member.id);
    console.log(members); // [ '143100912687251456', '143100912687251622' ]
  }
}

The issue is that it does not update properly if the user changes channels. If I restart the bot, and run the command, it executes perfectly. But if I were to change to another voice channel, it still thinks I am in the old one and not the new one.

This is probably because it is fetching some sort of cache. Does anyone know how to fetch their API directly instead of a local cache that isn't updating?

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Add GuildVoiceStates Intent

    intents: [
        GatewayIntentBits.GuildVoiceStates,
    ],
almost 4 years ago · Santiago Trujillo 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