Files
aurorabot/shared/modules/guild-settings/CLAUDE.md
syntaxbullet 56db5bc998 refactor(games): rework room lifecycle events and remove chess plugin
Consolidate room leave/delete event handling into RoomManager emitter,
remove redundant PLAYER_LEFT publishes from GameServer, and delete the
chess game plugin (board, types, tests) in favor of the new plugin
architecture. Add per-module CLAUDE.md files for leveling, guild-settings,
feature-flags, db, api, and panel to improve agent navigability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 15:19:51 +02:00

1.4 KiB

Guild Settings Module

  • updateSetting() uses a hardcoded keyMap to map friendly key names to DB columns. Use exact key names (e.g., "studentRole" not "studentRoleId"). Unknown keys throw UserError.
  • Type coercion per column: Discord IDs → BigInt automatically; colorRoleIds must be array; featureOverrides must be object; moderationDmOnWarn must be boolean; moderationAutoTimeoutThreshold must be number. Null values set columns to NULL.
  • Caching: getGuildConfig() (in shared/lib/config.ts) caches transformed settings for 60 seconds. Every mutation (upsertSettings, updateSetting, addColorRole, removeColorRole) calls invalidateGuildConfigCache(guildId) immediately.
  • If settings don't exist for a guild, the cache returns safe defaults — no errors thrown.
  • featureOverrides is a sparse Record<string, boolean> — no keys are predefined. Consumers must check key existence.
  • No Discord validation: The service does not verify that role/channel IDs actually exist in Discord. Invalid IDs are stored silently.
  • addColorRole() / removeColorRole() fetch the full settings, mutate the array in JS, then upsert — this is not atomic and can race under concurrent requests.
  • terminalMessageId and terminalChannelId are separate DB columns but grouped as terminal: { channelId, messageId } in the cached config. Setting one without the other can create orphaned data.