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

169
Visualizações
Unable to fetch all guild members through Discordjs v13

I have been trying to fetch the list of all members in my guild using the syntax as mentioned in the docs here. But am not receiving any output. Below is the code that I am using.

const { Client, Intents, Guild } = require("discord.js");
require("dotenv").config();
const commandHandler = require("./commands");
const fetch = require("node-fetch");

const client = new Client({
    intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_PRESENCES"],
});

client.once("ready", async (data) => {
    console.log("Ready!");
    console.log(`Logged in as ${client.user.tag}!`);
    const Guilds = client.guilds.cache.map((guild) => guild);
    console.log(Guilds[0]);
    await Guilds[0].members.fetch().then(console.log).catch(console.error);
});

client.on("interactionCreate", async (interaction) => {
    if (!interaction.isCommand()) return;

    if (interaction.commandName === "ping") {
        await interaction.reply(client.user + "💖");
    }
});

client.on("messageCreate", commandHandler);
client.login(process.env.BOT_TOKEN); // Kushagra's bot

I am getting the information on Guild instance through the console.log on line 13. But do am not getting any output for line 15. However, I noticed that I was getting some output if I add options to fetch() command on line 14. I received some output when I added {query: 'random text'}.

Just wanted to understand why I am unable to get a list of all members. Thanks!🙂

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found that I had missed out on the Intent. It seems that in order to fetch members you need to add an intent GUILD_MEMBERS while creating a client instance.

So replacing the client creation with the one below will work.

const client = new Client({ 
    intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_PRESENCES", "GUILD_MEMBERS"] 
});
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