Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

283
Views
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 answers
Answer question

0

Add GuildVoiceStates Intent

    intents: [
        GatewayIntentBits.GuildVoiceStates,
    ],
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!