Refresh repository documentation
Some checks failed
Deploy to Production / test (push) Failing after 33s

- Rewrite AGENTS and README files to match the current app layout
- Document API routes, trivia UI, and the active panel design language
This commit is contained in:
syntaxbullet
2026-04-09 21:10:10 +02:00
parent 8369d10bab
commit 6abbd4652a
17 changed files with 893 additions and 639 deletions

View File

@@ -1,9 +1,24 @@
# Feature Flags Module
# Feature flags module
- **No caching.** Every `isFlagEnabled()` and `hasAccess()` call hits the database directly.
- `isFlagEnabled(flagName)` checks global on/off state. `hasAccess(flagName, context)` checks both global state AND per-entity access records (guild, user, or role).
- Access logic: flag must be globally enabled AND user must have an explicit access grant. Grants can target guildId, userId, or roleId independently.
- Commands declare `beta: true` and optionally `featureFlag: string` in the Command interface. `CommandHandler` intercepts beta commands and calls `hasAccess()` before execution.
- If a command has no explicit `featureFlag`, the command name (`interaction.commandName`) is used as the flag name fallback.
- Flag names are case-sensitive. Convention is snake_case or camelCase — no enforcement.
- Admin management via `/featureflags` command: CRUD on flags and access grants/revokes.
## Behavior
- no in-memory caching; each check reads from the database
- a flag must exist and be globally enabled before any access grant matters
- grants can target a guild, a user, or a role
## Main entrypoints
- `isFlagEnabled(flagName)`
- `hasAccess(flagName, { guildId, userId, memberRoles })`
- `createFlag(name, description?)`
- `setFlagEnabled(name, enabled)`
- `grantAccess(flagName, { guildId?, userId?, roleId? })`
- `revokeAccess(accessId)`
- `listFlags()`
- `listAccess(flagName)`
- `deleteFlag(name)`
## Command integration
- `bot/lib/handlers/CommandHandler.ts` checks beta commands through this service
- if a command does not set `featureFlag`, the slash command name is used as the fallback flag name