Repository navigation
Conversation
El-Limon
left a comment
There was a problem hiding this comment.
Self-review: three non-obvious reliability decisions worth checking closely.
| const lockOwner = await acquireBloodMonitorLock(gameServerId, mod.moduleId); | ||
|
|
||
| try { | ||
| const installation = await getCurrentModuleInstallation(gameServerId, mod.moduleId); |
There was a problem hiding this comment.
Queued Takaro jobs contain an installation snapshot. Refreshing the current installation only after acquiring the lock prevents an older queued job from applying stale interval/channel configuration after a reinstall.
| } | ||
| if (!sameHistory(storedDelivered, delivered)) { | ||
| await renewBloodMonitorLock(gameServerId, mod.moduleId, lockOwner); | ||
| await writeVariable(gameServerId, mod.moduleId, BLOOD_DELIVERED_KEY, delivered); |
There was a problem hiding this comment.
The write order here is intentional: migrate/initialize delivery history before replacing observed state, then persist pending work before Discord. This closes the crash window where an unsent current phase could be mistaken for legacy-delivered.
| } | ||
| } | ||
|
|
||
| export async function acquireBloodMonitorLock(gameServerId, moduleId) { |
There was a problem hiding this comment.
The variable-backed lock serializes scheduled/manual overlap. Ownership checks, lease renewal, bounded backoff, stale record-id reclamation, and owner-safe release are each covered through real Takaro integration cases.
Summary
Fix Discord monitoring failures in
discord-7d2d-status-bridgeand make Blood Moon notifications reliable when Discord rejects delivery. The module now reports actionable authorization errors, checks phase transitions every minute, preserves unsent announcements for retry, and can privately warn the first player who joins on a Blood Moon day.This addresses field feedback where chat relay worked but monitoring calls failed even after granting the game bot administrator rights. Discord delivery still requires the Takaro Discord integration to be authorized for the guild and channel.
Architecture
What Changed
10008 Unknown Message, not generic failures.gettimeevery minute while leaving the heavier server-status update at five minutes. Daily intervals correctly represent the current Blood Moon day while also queuing the previous ending announcement.1, retries, stale queued jobs, lock expiry/timeout, message localization, and first-player behavior.Reviewer Guide
modules/discord-7d2d-status-bridge/src/cronjobs/blood-moon-monitor/index.jsTesting Plan
Happy Path
bloodMoonMonitor; verify day/start/end messages arrive once.privateBloodMoonNoticeOnFirstJoin, join as the only player duringtoday:orstart:, and verify the private warning.hordeIntervalDaysto1after 04:00; verify the current state istoday:<day>and ending/today announcements retain their order.Edge Cases
Regression Checks
npm run buildandnpm run typecheck.modules/discord-7d2d-status-bridge/test/bridge.test.ts.Verification Evidence
200 OK.gettime, refreshed the current installation, persisted the expected daily-interval state, and released the monitor lock.200 OKremains an environment/configuration gate rather than a code claim.