A Discord bot that integrates with iRacing to automatically track and post race results for linked Discord users. This bot monitors race activity and posts results to designated channels in real-time.
- Account Linking: Link Discord accounts to iRacing profiles using Customer ID
- Race Result Tracking: Automatic monitoring of race results for all linked users
- Real-time Notifications: Posts race results to designated channels as they happen
- Admin Controls: Server administrator controls for managing linked accounts and race log channels
- Rich Embeds: Beautiful race result embeds with position colors, iRating changes, and incident counts
/link <customer_id>- Link your Discord account to an iRacing profile using your Customer ID/unlink- Unlink your Discord account from iRacing
/link <customer_id> <discord_user>- Link another user's account to iRacing/unlink <discord_user>- Unlink another user's account/race-log- Configure the current channel to receive race result notifications
- Link Accounts: Users (or admins) link Discord accounts to iRacing profiles using their Customer ID
- Configure Channels: Admins use
/race-logto designate channels for race result notifications - Automatic Tracking: The bot continuously monitors iRacing for new race results from linked users
- Real-time Posts: When new results are found, rich embeds are posted to all configured race log channels
Each race result post includes:
- Driver: Discord mention and iRacing username
- Position: Final finishing position with ordinal suffix (1st, 2nd, 3rd, etc.)
- Track: Track name and configuration
- Car: Vehicle used in the race
- Incidents: Total incident count
- Event Type: Race, Qualifying, Time Trial, or Practice
- iRating Change: Before/after iRating with change indicator (if available)
- Color Coding: Gold for 1st place, silver for podium, bronze for top 10, gray for others
- Node.js 18 or higher
- Docker (optional, for containerized deployment)
- Discord Bot Token
- iRacing account credentials
Create a .env file based on .env.example:
DISCORD_TOKEN=your_discord_bot_token_here
IRACING_USERNAME=your_iracing_username
IRACING_PASSWORD=your_iracing_passwordNote: You can use either your raw iRacing password or pre-hash it and use IRACING_HASHWORD instead of IRACING_PASSWORD.
- Install dependencies:
npm install- Build the TypeScript code:
npm run build- Start the bot:
npm startFor development with auto-reload:
npm run dev- Build the Docker image:
docker build -t iracing-discord-bot .- Run with docker-compose:
docker-compose up -dThe bot is built with:
- TypeScript for type safety and better development experience
- Discord.js v14 for Discord API interactions
- SQLite3 for local data storage and race result history
- Axios for HTTP requests to iRacing API
- Automated Polling for checking new race results every 10 minutes
src/
├── bot.ts # Main bot implementation with race result tracking
├── database.ts # SQLite database operations for users, race results, and channels
└── iracing-client.ts # iRacing API client with race result search capabilities
discord_id(TEXT PRIMARY KEY) - Discord user IDiracing_username(TEXT) - iRacing display nameiracing_customer_id(INTEGER) - iRacing customer IDcreated_at(DATETIME) - Link creation timestamp
id(INTEGER PRIMARY KEY) - Unique result IDsubsession_id(INTEGER) - iRacing subsession IDdiscord_id(TEXT) - Discord user IDiracing_customer_id(INTEGER) - iRacing customer IDseries_id,series_name- Series informationtrack_id,track_name,config_name- Track informationcar_id,car_name- Car informationstart_time(DATETIME) - Race start timefinish_position(INTEGER) - Final positionstarting_position(INTEGER) - Starting positionincidents(INTEGER) - Total incidentsirating_before,irating_after- iRating before/after raceevent_type(TEXT) - Race, Qualifying, etc.official_session(BOOLEAN) - Whether it was an official session
channel_id(TEXT PRIMARY KEY) - Discord channel ID for race result postsguild_id(TEXT) - Discord guild IDcreated_at(DATETIME) - Configuration timestamp
series_id(INTEGER PRIMARY KEY) - iRacing series IDseries_name(TEXT) - Full series nameseries_short_name(TEXT) - Short series namecategory(TEXT) - Racing category (Road, Oval, etc.)category_id(INTEGER) - Category ID
The bot performs the following monitoring cycle:
- User Polling: Every 10 minutes, check all linked users for new race results
- API Queries: Use iRacing's series search API to find recent results
- Deduplication: Compare against stored results to avoid posting duplicates
- Result Processing: Fetch detailed subsession data for complete race information
- Channel Broadcasting: Post rich embeds to all configured race log channels
To link your account, you need your iRacing Customer ID (not your username). You can find this:
- Log into members.iracing.com
- Go to your profile or account settings
- Your Customer ID is displayed as a number (e.g., 123456)
- The bot only stores Discord IDs, iRacing Customer IDs, usernames, and race result data
- No sensitive iRacing account information is stored
- Race results are public information available through iRacing's official API
- Data is stored locally in SQLite database files
- Fork the repository
- Create a feature branch
- Make your changes following TypeScript best practices
- Test thoroughly with actual iRacing integration
- Submit a pull request
MIT License - see LICENSE file for details.
This version completely replaces the previous leaderboard-based functionality with race result tracking. If upgrading from an older version, you may need to:
- Update your Discord bot commands (old
/trackand/untrackcommands are removed) - Reconfigure channels using the new
/race-logcommand - Re-link users if needed (the linking system has been improved)