AnIdiotsGuide/discordjs-bot-guide

Wrong referral being tracked

markman641 opened this issue · 1 comments

I've had an intermittent issue with this code, and I think I finally figured out what's wrong.
The wrong members were being credited with the invite. It would credit the same member multiple times in a row.

It appears that after a guildMemberAdd, the invite cache is not being updated. So I added this line

//update the *existing* invites for the guild.
client.invites.set(member.guild.id, new Map(newInvites.map((invite) => [invite.code, invite.uses])));

to the guildmemberadd event to update the invites. haven't tested yet but wanted to get this out there.

Was submitted without testing, seemed to be an abandoned issue but will investigate.