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
MrMythical2y ago
you just don't... there really isn't any reason to
AnthonyVault
AnthonyVault2y ago
When my bot is starting, he cant track old invites
MrMythical
MrMythical2y ago
and why do you need the invites?
AnthonyVault
AnthonyVault2y ago
Get member who invited
MrMythical
MrMythical2y ago
I still don't see
AnthonyVault
AnthonyVault2y ago
Then, any other solutions to get inviter of new member?
lupus
lupus2y 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.