Case study
Asuka RS
2025 - alpha Sole developer
Summary
Asuka RS is an alpha Rust side project, an event-driven Discord bot. I built it around independent event tasks, two separate command registries, cache-first lookups, localized responses, and support for 31 locale codes. It is a study in giving each concern its own boundary instead of collapsing everything into one handler.
Context
The project explores a bot architecture that routes text and interaction commands, manages user preferences, and offers configurable moderation controls, without one handler owning all of it. Rust makes the boundaries explicit, with independent tasks, typed command contexts, and caches whose eviction is part of the type rather than an afterthought.
Role
Sole developer. I owned the architecture, the Rust implementation, and the internationalization.
Runtime and event flow
One Twilight gateway shard receives the events. Each event goes into the Twilight message cache and then into its own Tokio task, so an error handling one event cannot stall the ones behind it. Raid-relevant events hit the anti-raid pre-filter first. After that, main_handler routes by event kind into one of two dispatch paths, text commands and interactions, which keep separate registries and validation.
Runtime / gateway to dispatch
Every event runs in its own task, on two registries
Buttons and select menus dispatch straight to their registered handler and deliberately skip the validation ladder, since the only way to reach them is a message the bot itself sent.
The command protection ladder
Both command kinds climb a ladder of checks before their handler runs, but not the same ladder. Allowance and user permissions are checked on both paths. A configured cooldown is claimed atomically before the rate limit is even tested, and only then does the handler run. Slash commands also verify bot permissions and can load the database user when a tiered limit needs their tier. The text path currently does neither.
Command protection / the check ladder
Text and slash commands climb different ladders
Cache-first data access
User access is cache-first through an in-memory Moka cache. A hit never touches the database. A miss makes UserService upsert the user through Prisma, cache the resulting model, and return it. The user and server caches are each capped at 100 MiB with a one-hour time-to-idle expiry, and the user cache weighs entries from the key and language length.
Data access / cache-first
A cache miss upserts SQLite, then repopulates the cache
Cooldowns, rate-limit counters, and anti-raid detection windows each get their own async Moka cache, so none of them adds database pressure. That is the pattern. State that is cheap to rebuild stays in memory with a bounded weight and a TTL; only durable facts reach SQLite.
Internationalization
User-facing strings go through fluent-templates, one .ftl file per locale under locales/. The language resolves from Discord’s interaction locale, normalized against the 31 application locale codes, and a changed preference is written to the database and the cache together. Every lookup carries a colocated fallback, and the Fluent fallback language is English, so a missing key degrades to readable text instead of an error.
Internationalization / Fluent
Discord's locale, the saved preference, then English
31 locale codes
Supported in one system
Translation coverage is not assumed complete. Locale files may still carry generated TODO: translate placeholders, so a dedicated locales binary scans the source for lookup calls and synchronizes the .ftl files, adding missing keys and removing dead ones.
Anti-raid
Guild protection runs as a pre-filter on raid-relevant events. Mass joins, repeated messages, message saturation, and destructive role or channel spikes are tracked in in-memory sliding windows, so detection never queries the database on the hot path, and per-guild configuration is cached and loaded on demand. When a window crosses its threshold, a configurable action ladder decides the response, from silent logging up to a full lockdown. A development guild is always treated as test mode.
Anti-raid / detection to response
Sliding windows in memory, an action ladder per guild
Tradeoffs
Independent event tasks were the right concurrency model for the MVP, and they made the next need obvious. There is no API or dashboard yet, so configuration is code and data rather than a product surface. Bounded in-memory caches for cooldown, rate-limit, and detection state keep SQLite for durable facts, at the cost of that state being per-process and lost on restart.
Reliability & Security
The implementation includes multi-layer permissions, per-user cooldowns, optional and tiered rate limits, parameterized Prisma queries, localized errors, and configurable anti-raid responses. A failed command stays isolated in its own task and becomes a localized Discord reply instead of crashing the bot. These are implementation controls, not production-scale guarantees.
What I would improve
I would add an API and a dashboard before a broader release, so guild configuration and moderation settings become a product surface instead of database rows.
Building an event-driven integration that needs clear boundaries and a maintainable core? Discuss your project.