Invite Tracker
by Bot-Hosting Node.js Social & Community Official See who invited whom: join messages with the inviter, leaderboard, fake-invite detection and reward roles for invite goals.
Know exactly who brings members to your server. The bot remembers every invite link and, when someone joins, credits the member who invited them. It also spots fake invites (brand-new accounts), counts members who left, and can hand out roles automatically when someone reaches an invite goal. Perfect for invite contests and growth campaigns.
What it does
- Who invited whom: join and leave messages that name the inviter, including vanity URLs and single-use invites.
- Leaderboard:
/leaderboardranks your best inviters,/invitesshows anyone's stats (regular, left, fake, bonus). - Fake detection: accounts younger than a threshold you choose do not count.
- Reward roles: give a role automatically at 5, 10, 50 invites...
- Staff tools: add, remove or reset invites, and resync them.
1. Create the bot on Discord
- Open the Discord Developer Portal and click New Application.
- On General Information, copy the Application ID (
CLIENT_ID). - Go to Bot, click Reset Token and copy it (
DISCORD_TOKEN). - Still on Bot, turn on Server Members Intent.
- Go to OAuth2 > URL Generator, tick
botandapplications.commands, give it Manage Server (to read invites), Manage Roles (for rewards), Send Messages and Embed Links, then add it to your server. Put the bot's role above the reward roles.
2. Deploy
Fill the variables and click Deploy. Set GUILD_ID to your server ID to get the commands instantly (global commands can take a few minutes).
3. Configure
/config channel: where join and leave messages go./config message: customize the join and leave texts./config fake-threshold: minimum account age (in days) for an invite to count./reward add: give a role at a number of invites./config view: check your settings./helplists everything.
Good to know
- Invites created before the bot joined are picked up when it starts, so add the bot before your campaign.
- Data is saved in
data/database.jsonwith your files.
šÆ Discord Invite Tracker Bot
An advanced, production-ready Discord Invite Tracker Bot built with Discord.js v14. It delivers real-time invite tracking, Discord Vanity URL detection, anti-alt account filters, automated milestone role rewards, interactive paginated leaderboards, and fully customizable join/leave embed logs.
⨠Key Features
- ā” Real-Time Invite Caching Engine: Automatically captures and syncs invite uses across every guild without missing joins.
- š Vanity URL & OAuth Detection: Seamlessly distinguishes between regular invites, server vanity URLs (
discord.gg/vanity), and bot integrations. - š”ļø Anti-Alt / Fake Account Detection: Automatically calculates account creation age on join. Accounts younger than a configurable threshold (e.g. 3 days) are flagged as
Fakeand excluded from valid invite totals. - šŖ Precise Member Departure Attribution: Tracks which user originally invited a departing member and automatically adjusts the inviter's stats (
left + 1,regular - 1). - šļø Automated Milestone Role Rewards: Set up reward milestones (e.g., 5 invites ā Bronze, 10 invites ā Silver). The bot awards roles instantly when goals are met.
- š Interactive Paginated Leaderboard: Dynamic top 10 inviters display with gold, silver, and bronze badges (š„ š„ š„) and interactive button navigation (
āļø Previous/Next ā¶ļø). - š Detailed User Profile (
/invites): View regular, left, fake, and bonus invites, win retention rate %, active invite codes, and a visual progress bar toward the next milestone. - š Rich Template Interpolation: Customize welcome and leave messages with dynamic variables (
{user},{inviter},{invites},{total},{guild.name},{code},{memberCount}). - š¾ Zero-Dependency Atomic Storage: Fast, persistent JSON database with in-memory caching and atomic temporary writes to eliminate race conditions and corrupted data.
- š”ļø Slash Commands Only: Built exclusively with Discord Application (/) Slash Commands, compliant with modern Discord API standards.
šø Preview & Showcase
+-----------------------------------------------------------+
| š Invite Statistics ā Hashir |
| Detailed invite breakdown and tracking record. |
| |
| šÆ Total Invites: 24 Invites |
| ā
Regular: 26 members | šŖ Left: 3 departed |
| š¤ Fake/Alt: 1 flagged | š Bonus: +2 awarded |
| š Retention Rate: 90% retained |
| |
| šļø Milestone Progress |
| Next Goal: @Gold Inviter (30 invites) |
| [ā°ā°ā°ā°ā°ā°ā°ā°ā±ā±] 80% (6 more needed) |
| |
| š Active Invite Links |
| ⢠discord.gg/abcXYZ ā 14 uses |
| ⢠discord.gg/def123 ā 12 uses |
+-----------------------------------------------------------+
š Slash Commands Reference
š Member Commands
| Command | Description |
|---|---|
/invites [user] |
View your own or another member's invite statistics, active codes, and milestone progress. |
/leaderboard [page] |
View the server's top inviters with interactive pagination buttons. |
/ping |
Check bot latency, Discord WebSocket heartbeat, memory usage, and uptime. |
/help |
Display an interactive directory of all bot commands and template tags. |
āļø Server Configuration (Manage Guild Required)
| Command | Description |
|---|---|
/config view |
Inspect current server channels, message templates, and anti-alt settings. |
/config channel <type: join|leave> <channel> |
Set notification channels for member joins and leaves. |
/config message <type: join|leave> <template> |
Set customized join or leave notification messages. |
/config fake-threshold <days> |
Set the minimum account age (in days) to flag suspicious alt accounts. |
/config embed-color <hex> |
Customize the bot's embed highlight color (e.g. #5865F2). |
šļø Role Rewards (Manage Roles Required)
| Command | Description |
|---|---|
/reward add <invites> <role> |
Create or update a role reward granted when a member reaches an invite count. |
/reward remove <role> |
Remove an existing role reward milestone. |
/reward list |
Display all active role reward milestones configured on the server. |
ā” Administration (Administrator or Manage Guild Required)
| Command | Description |
|---|---|
/add-invites <user> <amount> [reason] |
Award bonus invites to a member (e.g., for events, giveaways). |
/remove-invites <user> <amount> [reason] |
Deduct invites from a member. |
/reset-invites <user> |
Reset a member's invite record back to zero. |
/sync-invites |
Force re-sync and rebuild all server invites into memory cache. |
š·ļø Message Template Variables
You can use the following placeholders inside /config message:
| Placeholder | Replaced With | Example |
|---|---|---|
{user} |
Mention of the joined/left user | @Hashir |
{user.tag} |
Username and tag of user | Hashir#0001 or hashir |
{user.id} |
Discord Snowflake ID of the user | 987654321012345678 |
{inviter} |
Mention of the inviter (or Vanity / OAuth) | @Alex |
{inviter.tag} |
Tag of the inviter | Alex#1234 |
{invites} / {total} |
Inviter's net total valid invites | 15 |
{regular} |
Number of active members still in the server | 18 |
{left} |
Number of invited members who departed | 3 |
{fake} |
Number of invited accounts flagged as alts | 1 |
{bonus} |
Admin-awarded bonus invites | 2 |
{code} |
The specific invite code used | xYz89P |
{guild.name} |
Current server name | Developers Hub |
{memberCount} |
Current total server member count | 1,248 |
š Quick Setup & Installation
1. Prerequisites
- Node.js: v18.0.0 or higher
- Discord Bot Token: From the Discord Developer Portal
2. Enable Privileged Gateway Intents
In the Discord Developer Portal:
- Select your Application ā Bot tab.
- Scroll down to Privileged Gateway Intents.
- Enable Server Members Intent (
GUILD_MEMBERS). - Ensure the bot has permissions to:
Manage Server(to fetch server invites)Manage Roles(to grant milestone role rewards)Send Messages&Embed Links
3. Clone Repository & Install Dependencies
# Clone the repository
git clone https://github.com/hashiryahya/discord-invite-tracker.git
# Navigate to project directory
cd discord-invite-tracker
# Install required dependencies
npm install
4. Configure Environment Variables
Copy .env.example to .env:
cp .env.example .env
Open .env and fill in your credentials:
DISCORD_TOKEN=your_bot_token_here
CLIENT_ID=your_application_client_id_here
GUILD_ID=your_test_guild_id_here # Optional: For instant testing
DATABASE_PATH=./data/database.json
5. Register Slash Commands
npm run deploy-commands
6. Start the Bot
# Production mode
npm start
# Development mode (auto-reload on code change)
npm run dev
š³ Docker Deployment
A Dockerfile is provided for containerized deployments:
# Build the Docker image
docker build -t discord-invite-tracker .
# Run the container
docker run -d --name invite-bot \
-e DISCORD_TOKEN="your_token" \
-e CLIENT_ID="your_client_id" \
-v $(pwd)/data:/app/data \
--restart unless-stopped \
discord-invite-tracker
š Project Architecture
discord-invite-tracker/
āāā .env.example # Environment variables template
āāā .gitignore # Git ignore patterns
āāā Dockerfile # Docker container configuration
āāā LICENSE # MIT License
āāā package.json # NPM package manifest & scripts
āāā README.md # Project documentation
āāā data/
ā āāā .gitkeep # Git tracking placeholder
ā āāā database.json # Persistent JSON database (auto-generated)
āāā src/
āāā config.js # Configuration defaults loader
āāā deploy-commands.js # Slash command registration script
āāā index.js # Application entry point & client init
āāā commands/ # Slash commands organized by category
ā āāā admin/
ā ā āāā addInvites.js
ā ā āāā config.js
ā ā āāā removeInvites.js
ā ā āāā resetInvites.js
ā ā āāā reward.js
ā ā āāā syncInvites.js
ā āāā general/
ā ā āāā help.js
ā ā āāā ping.js
ā āāā invites/
ā āāā invites.js
ā āāā leaderboard.js
āāā database/
ā āāā db.js # Atomic, thread-safe JSON database service
āāā events/ # Discord Gateway event handlers
ā āāā guildCreate.js
ā āāā guildDelete.js
ā āāā guildMemberAdd.js
ā āāā guildMemberRemove.js
ā āāā interactionCreate.js
ā āāā inviteCreate.js
ā āāā inviteDelete.js
ā āāā ready.js
āāā services/
ā āāā inviteTracker.js # Real-time invite detection & caching engine
āāā utils/
āāā formatters.js # Template parser, duration & embed helpers
š¤ Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the Project (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
š License
Distributed under the MIT License. See LICENSE for more information.
šØāš» Author
Hashir Yahya
- Website: hashiryahya.online
- GitHub: @hashiryahya
- Portfolio: hashiryahya.github.io