TheShadowGamer / Invite-Manager

Invite manager is an open-source discord bot that allows you to track the invites of people who join your server.
MIT License
117 stars 61 forks source link

Support for existing invites #11

Closed VenomTR closed 3 years ago

VenomTR commented 3 years ago

I have a feature request, currently invites are only tracked once the bot starts/invited Is it possible to include a feature where it collects already existing invites?

TheShadowGamer commented 3 years ago

It already does (If i'm understanding you correctly). Look at these lines https://github.com/TheShadowGamer/Invite-Manager/blob/master/listeners/ready.js#L22-L26


client.guilds.cache.forEach(async guild => {
    let invites = await guild.fetchInvites();
    if(guild.vanityURLCode) invites.set(guild.vanityURLCode, await guild.fetchVanityData());
    guildInvites.set(guild.id, invites);
});
VenomTR commented 3 years ago

I just downloaded again so everything was fresh, started the bot, commands work etc. but still says "has 0 invites!" but the user I mentioned has 5 invites according to the Discord Invites section, any idea why this would be happening? (Bot accounts has required intents, is an admin in the server and the bot role is at the top of the role list)

TheShadowGamer commented 3 years ago

Ah so that’s what you mean. My bad, I misunderstood you. Discord does not track who invites who, which is the main point of the bot. So the bot has to track all that itself. Basically what the bot does is, when someone new joins it gets all the new invites and compares them with the old invites to find one where the old invites is less than the new. Now, this wouldn’t work if the bot is offline since it can’t know when a member joins, so that’s not fully possible. Someone suggested to store the old in a DB, and compare it to the new ones when the bot starts, but that wouldn’t work because their could have been more than one change.

tl;dr Not possible, can’t do anything. Look into a VPS for the bot to be up 24/7 and store invites fully, and it’ll start tracking from the moment you turn it on until you turn it off.