I’m working on a Discord bot that gives rewards based on how many people users invite to the server. The problem is that people can fake their invite numbers pretty easily so I need to find a way to stop cheaters.
Here’s what I have so far:
[Command("checkinvites")]
public async Task ValidateInvites()
{
var inviteList = await Context.Guild.GetInvitesAsync();
foreach (var invite in inviteList)
{
if (Context.User.Username + "#" + Context.User.Discriminator == invite.Inviter.ToString())
{
// show invite count
await Context.Channel.SendMessageAsync(invite.Uses.ToString());
}
}
}
I thought about tracking when someone joins and figuring out which invite they used but it seems like the Discord API doesn’t give you that info directly. I found some documentation about IInviteMetadata but I’m not sure how to actually use it in my code.
What I really want is a bot that can count real invites only. If someone joins but then leaves right away their invite shouldn’t count. Also maybe make people stay for like 10 minutes before their invite counts as valid.
Your problem is you’re only checking static invite counts - super easy to game. Here’s what actually works: I built a dual-tracking system that monitors guild member events AND keeps a cache of invite usage data. When someone joins, I snapshot all current invites, compare it to my previous snapshot to see which invite got used, then log that join with a timestamp. After your validation period (whatever you set), I run a background task to check if the user’s still there and active before giving the inviter credit. Stops both the quick join-leave BS and makes sure you’re only rewarding real community growth. BTW, IInviteMetadata just gives you extra invite properties - won’t fix your tracking issue.
I ran into this same problem building my server’s growth tracker. You need to store invite snapshots and compare them when people join. Set up a database table for invite codes with usage counts, then update it regularly. When someone joins, compare current counts with stored data to see which invite they used. For time validation, run a scheduled task that only marks invites as valid after users stay active for however long you want. Don’t forget edge cases - temp invites and people joining through server discovery won’t show up in your tracking.
you’ll have to log member joins and save guild invite states before and after each join. then, set up a delayed task to check the invite after 10 mins - if they’re still around, count it as legit.