The Mayling Bot & AK Guesser
LiveOngoing personal projectBot & game code private
A private Discord bot built for a friend’s community (an unofficial reference to Mayling from Girls’ Frontline 2) that also hosts AK Guesser, an embedded daily Arknights guessing game inside Discord.
436 operators in 2 daily modes promoted Sep 14, 2026
Artwork (1,232 entries) and Skill icons (810 skills) live in AK Guesser, backed by 2,044 hashed Cloudflare R2 assets.
$0 AK Guesser hosting cost as of Sep 2026
AK Guesser stays inside Cloudflare Workers, R2, and Supabase free tiers via generate-once crop caching.
Jul 10 Discord App Verification 2026
Verified for embedded Discord Activity play, backed by public privacy and terms documentation.
Architecture and ownership
- DiscordCommunity server
- Fly.ioThe Mayling BotTypeScript and discord.jsCloudflare WorkerAK GuesserReact 19 and Hono API
- DatabaseSupabase PostgresMedia and assetsCloudflare R2
- Indexes the media catalogPriestess
The Mayling Bot runs outbound-only on Fly.io in TypeScript and discord.js, backed by Supabase Postgres, Cloudflare R2, pino structured logging, and Zod config validation. It handles admin triggers, scheduled jobs, YouTube upload notifications, and the shared R2 media catalog that Priestess indexes.
AK Guesser launched on July 10, 2026 as a verified Discord Activity inside the server, then expanded on September 14, 2026 to two five-round daily modes (Artwork crops and Skill icons) plus unranked play. A single Cloudflare Worker serves the React 19 interface, Hono API, server-side WebP crop generation, and Hyperdrive Postgres queries.
Coding agents write the implementation while I direct the system architecture, product rules, verification checks, and releases.
Bot and game repositories stay private. Only the Astro 7 privacy and terms documentation site is public.
Systems engineering notes
Server-authoritative answer secrecy with HMAC-SHA256Jul–Sep 2026Prevented players from enumerating daily answers through Cloudflare R2 image URLs across a 436-operator catalogue.
Plain hashes of artwork names were enumerable against the public operator roster. Every 1120x960 WebP artwork crop and daily skill icon now uses an HMAC-SHA256 R2 key bound to a server secret, date, round, and pipeline version. Daily target generation takes a PostgreSQL advisory transaction lock (pg_advisory_xact_lock) so concurrent players at UTC midnight rollover never duplicate image transforms.
Making wrong-environment deploys fail by designJul 13, 2026After a shared build shipped the dev Discord app ID live, rebuilt the pipeline so mixed environments cannot deploy.
Split build outputs into separate dist/dev and dist/prod folders with explicit app IDs and added a post-build verifier (verify-bundle-app-id.mjs) that scans every JS chunk against an independent environment table and rejects dev routes in live builds. Bare npm run build and bare wrangler deploy now exit with an error instead of guessing an environment.
Discord Activity CSP and edge-cache workaroundsJul 2026Worked around Discord’s embedded iframe proxy caching index.html and blocking external avatar hosts.
Because Discord’s proxy blocks direct cdn.discordapp.com loads under Activity Content Security Policy, the Worker proxies avatars same-origin only for known player IDs in PostgreSQL (never an open proxy). Because the proxy also strips cache headers from text/html and edge-caches index.html, Vite emits a build-agnostic HTML shell that loads a Worker-served /boot.js script with no-store headers so every launch gets the latest hashed bundle.
Self-healing /help command cache inside Discord’s 3-second windowAug 2, 2026Fixed a deploy-order race where newly registered slash commands appeared as plain text until bot restart.
Command IDs were snapshotted once on startup, which raced post-deploy command registration. Added an on-miss guild command refetch throttled to once per 60 seconds and raced against a 1.5-second reply deadline inside Discord’s 3-second acknowledgement window. If the refresh loses the race, the bot answers with the existing cache while the refresh finishes in the background.