Discord Bot for iRacing Race Reports

Your league's races,
posted the moment they finish

SimBot Race Reports watches a list of iRacing drivers and posts a rich, image-based race card to Discord every time one of them finishes an official race or hosted session — podiums to their own channel, everyone else to the main feed.

1iRacing API call per driver, per poll
2–20mAdaptive polling cadence
5Charts per card, from one lap-chart call

What it does

Built to stay efficient toward iRacing's API while staying fast for active drivers.

Adaptive Polling Cadence

Re-check frequency scales with how recently a driver raced: every 2 min if they raced in the last 3 days, stepping back to a 20-minute ceiling when dormant. Active drivers stay near-realtime; idle ones cost almost nothing.

Cross-Driver Discovery

Every fetched race is scanned for other tracked drivers in the same field — including across different Discord servers. One API call can surface reports for several drivers at once.

Image Race Cards

Each report is a rendered dark-themed card: finish position, iRating & Safety Rating deltas, incidents, class strength of field, weather, and more — built from a single API response.

Race Charts

Inline SVG charts for position over laps (class vs. overall), lap times with pit stops and incidents marked, gap to the cars ahead and behind, and class pace comparisons — all from one lap-chart call, no charting library.

Podium Detection (In-Class)

Podiums are top-3 finish position within car class, not overall — correct for multiclass series where P8 overall can still be a class win.

Team & Endurance Races

Team results show the full roster sorted by iRating, with each driver's laps, iRating change, and Safety Rating change — real per-driver stats, not team placeholders.

Hosted & League Sessions

Hosted sessions are checked on their own, sparser schedule (10 min for active drivers, backing off to daily), so league nights get race cards too without slowing official polling.

On-Demand Lookups

Pull up any driver's profile card (licenses, career stats, Driver DNA), a tracked driver's race history, a report for any past race, or a team report comparing every teammate's pace and stints.

Dual Channel Routing

An "all races" channel and a "podiums only" channel can both be set at once — every race goes to one, podium finishes also go to the other.

Crash-Safe, No Duplicates

Every post is claimed in a dedup table before sending. A crash or restart mid-poll can never result in the same race being posted twice.

Guild & Interaction Logging

Every server the bot joins or leaves, and every slash command run, is logged for analytics and debugging — matching the rest of the SimBot suite.

Raw Data Archival

Every race result, lap chart, and recent-races response is cached verbatim in the database — a foundation for future stats without re-hitting the iRacing API.

Embed Fallback

If image rendering ever fails, the report still posts as a Discord embed — a report is never dropped for a rendering hiccup.

Command Reference

Commands labeled Admin Only require the Manage Server permission. Parameters marked ? are optional.

How It Works

From server setup to a race card landing in Discord.

01

Admin Configures Channels

An admin runs /racereports-admin setup to pick an all-races channel and/or a podiums-only channel. The bot verifies it can actually post there before saving.

02

Drivers Track Themselves

A user runs /racereports track with their iRacing customer ID. Their watermark is seeded to their most recent existing race — no history spam, only new races going forward.

03

The Poller Wakes on Schedule

A lightweight tick checks which drivers are due, based on their adaptive cadence. Due drivers are queried once via member_recent_races through a shared rate limiter.

04

New Race Detected

Any subsession newer than the stored watermark triggers a full results/get fetch — this single response carries weather, splits, standings, and per-driver stats for the card.

05

Card Rendered

A lap-chart call feeds the position and lap-time charts, then the whole card is rendered to an image. If rendering fails for any reason, an embed is posted instead — nothing is dropped.

06

Fan-Out & Dedup

The report is posted to every server that tracks the driver — all-races channel always, podium channel if it's a top-3-in-class finish — with a dedup claim guaranteeing no double-posts.

Architecture

A single long-running Node process — no webhooks required, since iRacing doesn't offer any.

Discord Gateway

A persistent discord.js WebSocket connection handles slash commands and posts reports — no HTTP interactions endpoint to host.

iRacing Client

OAuth2 Password Limited Grant, with access tokens cached in Redis and refreshed automatically. All calls run through one queue (about 50 calls/min), coordinated through Redis so the website and other SimBot bots on the same account share the limit.

MySQL

Drivers, per-guild config, subscriptions, dedup log, guild/interaction analytics, and raw API archives — all in parameterized queries, no ORM.

Race Lookup Website

A separate Express process serves a browser UI for searching drivers and opening full race reports, sharing the bot's MySQL, Redis, and iRacing client.

Puppeteer + Handlebars

The race card is a Handlebars template rendered to PNG via headless Chromium, with charts drawn as plain inline SVG.

Add it to your server

SimBot Race Reports is hosted for you. There's nothing to install: invite the bot, pick your channels, and start tracking drivers.

1

Invite the bot

You need the Manage Server permission. The bot asks for View Channel, Send Messages, Embed Links, and Attach Files (race cards post as images).

Add to Discord
2

Pick your channels

Run /racereports-admin setup to choose an all-races channel and/or a podiums-only channel. The bot checks it can post there before saving.

3

Track your drivers

Each driver runs /racereports track with their iRacing customer ID, or an admin adds them with /racereports-admin add-driver. Only races from then on are posted.

4

Check it works

Run /racereports-admin status to confirm channels and permissions, or /racereports-admin test to post a driver's latest race right away.