# Invite Tracking

InviteCount automatically tracks every invite on your server. When a member joins, the bot identifies who invited them and updates the inviter's stats in real-time.

***

## How It Works

1. **The bot monitors all invite links** — every time someone creates an invite, the bot records it.
2. **When a member joins**, the bot compares the invite usage counts before and after the join to determine which invite was used.
3. **The inviter's stats are updated** — their total invite count increases by one.

***

## Invite Types

Each inviter has four invite counters:

| Type        | Description                                         |
| ----------- | --------------------------------------------------- |
| **Regular** | Valid invites — members who joined and stayed       |
| **Leaves**  | Members who were invited but left the server        |
| **Fakes**   | Members flagged as fake by the detection system     |
| **Bonus**   | Manually added or removed invites by administrators |

### Total Invites Formula

```
Total = Regular + Bonus - Leaves - Fakes
```

***

## Fake Invite Detection

InviteCount detects suspicious joins using configurable flags. When a new member matches one or more flags, their join is counted as a **fake invite**.

### Detection Flags

| Flag               | Description                                                           |
| ------------------ | --------------------------------------------------------------------- |
| Young account      | Account is younger than the server's configured `fakedelay` (in days) |
| Self-invited       | User joined using their own invite link                               |
| No profile picture | User has no avatar set                                                |
| No profile banner  | User has no banner set                                                |
| Rejoin             | User has previously joined and left the server                        |
| AutoMod flagged    | User was flagged by Discord's AutoMod (username quarantine)           |

### Detection Modes

| Mode    | Behavior                                                      |
| ------- | ------------------------------------------------------------- |
| **ANY** | A join is flagged as fake if **any** enabled flag matches     |
| **ALL** | A join is flagged as fake only if **all** enabled flags match |

### Configure Fake Delay

Use `/fakedelay <days>` to set the minimum account age:

* `/fakedelay 7` — Accounts younger than 7 days are flagged as fake
* `/fakedelay -1` — Disables account age detection

***

## Viewing Invites

| Command                      | Description                                          |
| ---------------------------- | ---------------------------------------------------- |
| `/invites [@member]`         | View invite stats for yourself or another member     |
| :star2: `/inviter <@member>` | See who invited a specific member — **Premium only** |
| `/leaderboard invites`       | View the server's top inviters                       |

***

## Blacklist

Prevent specific users from being counted as valid inviters using the blacklist system:

```
/blacklist add <@member>
/blacklist remove <@member>
/blacklist list
/blacklist reset
```

When a blacklisted user's invite is used, the join is not counted toward their invite total.

***

## Tips

* Make sure the bot has the **Manage Server** permission to track invites correctly.
* If the bot was offline when a member joined, it may not be able to determine the inviter.
* Use `/add invites` and `/remove invites` to manually adjust invite counts when needed.
