Fetch all invites from all guilds

How can i fetch all invites from all guilds without API spam? This do api spam:
client.guilds.cache.forEach(async guild => {
if (guild.me && guild.me.permissions.has('MANAGE_GUILD')) {
const invites = await guild.invites.fetch({ cache: false }).catch(e => null)
guildInvites.set(guild.id, invites);
}
})
client.guilds.cache.forEach(async guild => {
if (guild.me && guild.me.permissions.has('MANAGE_GUILD')) {
const invites = await guild.invites.fetch({ cache: false }).catch(e => null)
guildInvites.set(guild.id, invites);
}
})
7 Replies
MrMythical
MrMythical3y ago
you just don't... there really isn't any reason to
ɅV
ɅVOP3y ago
When my bot is starting, he cant track old invites
MrMythical
MrMythical3y ago
and why do you need the invites?
ɅV
ɅVOP3y ago
Get member who invited
MrMythical
MrMythical3y ago
I still don't see
ɅV
ɅVOP3y ago
Then, any other solutions to get inviter of new member?
lupus
lupus3y ago
To my knowledge, you can only see who invited a member by looking which invite count of an invite increased by one after someone got invited, there is no property to find the inviter nor is there any other way at all. While this may work for small guilds - as you said - it is API Spam for bigger sized or multiple ones.
Want results from more Discord servers?
Add your server