Sentinel
A production Discord security and moderation bot, anti-raid detection, a 14-filter automod pipeline, ticketing, and audit logging, all mirrored live to a web dashboard.
The gateway layer holds a persistent WebSocket connection through Discord's full lifecycle: IDENTIFY on first connect, sequence-number tracking so a dropped connection can RESUME instead of losing session state entirely, and a heartbeat loop that has to fire on the server-dictated interval or the connection gets killed outright. Getting RESUME right, replaying the correct sequence number, falling back cleanly to a fresh IDENTIFY when Discord rejects it, was the part that actually took debugging.
Anti-raid detection runs on a sliding time window per guild: every join lands on a ring buffer with a timestamp, checked on each new join rather than on a fixed timer, so detection latency is as fast as the next event instead of lagging behind a polling interval. Cross a threshold, tuned per guild size so a 50-person server and a 50,000-person server are not held to the same flat number, and Sentinel locks the guild automatically: invites revoked, verification level raised, an alert fired to the mod log, before a human has opened the app.
Rate limiting against Discord's own API is implemented as a proper per-route token-bucket queue, reading X-RateLimit-Remaining and reset headers off every response rather than the lazier catch-429-and-sleep approach, which under real load risks a temporary ban on the whole application. The moderation pipeline keeps sequential per-guild case numbers and configurable escalation thresholds, mirrored to the dashboard over a second WebSocket channel so a moderator watching it sees a ban land the same second it happens, not on the next refresh.
Status
ActiveStack
TYPESCRIPT · DISCORD GATEWAY · WEBSOCKETS · POSTGRESQL · RATE LIMITING · ANTI-RAID