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

154
Views
How do i make my Bot list every Invite from my Servers (more info in question)

i've been trying to do a invites Command which should find all Invites from the Servers my Bot is on.
(ONLY MY OWN SERVERS)
I do have tried some ideas and code but nothing worked, how to implement it into my Discord Embed i do already know i just need help with the Invite Listing.

client.guilds.forEach(guild => {
    guild.fetchInvites().then(guildInvites => {
        invites[invites.length + 1] = (guild + " - `Invites: " + guildInvites.array().join(", ") + "`");
        ct++;
        if(ct >= client.guilds.size) {
            invites.forEach((invite, i) => {
                if(invite == undefined)
                    invites.splice(i, 1);
            }); 
            invites.shift();
            invites.forEach((invite, i) => invites[i] = "- " + invite);
            invites = invites.join("\n\n");
            let embed = new Discord.RichEmbed()
            .setTitle("All Invites:")
            .setDescription(invites);
            message.channel.send(embed);
        }
    })
});```

Help is much appreciated. 
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Are you caching your servers before fetching them? The cache is necessary so the bot can get information from each guild that it is in. Change the first line to

client.guilds.cache.forEach(() => {
  // ...
}

Got this code from this answer here.

about 4 years ago · Juan Pablo Isaza Report

0

From the previous answers and comments on them, I can guess that you either don't have the required intents when instantiating the client class, OR that maybe your client class is not correctly defined.

How do you define client? If it's from another file, try importing it correctly. Don't make multiple clients from a same token/process.

about 4 years ago · Juan Pablo Isaza Report

0

client.guilds.cache.map(guild => {

            let embed = new Discord.RichEmbed()
            .setTitle("All Invites:")



 guild.channels.cache
            .first()
            .createInvite()
            .then((invite) => embed.setDescription(invites.url);)
            .catch(() => embed.setDescription("Lien d'invitation", "Permission Invalides"));
            message.channel.send(embed);
})
about 4 years ago · Juan Pablo Isaza 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!