Refresh repository documentation
Some checks failed
Deploy to Production / test (push) Failing after 33s
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:
@@ -1,10 +1,28 @@
|
||||
# Moderation Module
|
||||
# Moderation module
|
||||
|
||||
- Case IDs are sequential strings formatted as `CASE-XXXX` (zero-padded to 4 digits). Generated by querying the latest case and incrementing. Not a DB sequence -- concurrent inserts could theoretically collide, but in practice moderation actions are low-frequency.
|
||||
- Only `WARN` type cases are created with `active: true`. All other case types (TIMEOUT, BAN, KICK, NOTE) default to `active: false`. The `active` flag is specifically for tracking unresolved warnings.
|
||||
- `issueWarning` has two side effects beyond creating the case:
|
||||
- **DM notification**: sends the user a warning embed via DM. Fails silently if the user has DMs disabled. Controlled by `config.dmOnWarn` (defaults to true if unset).
|
||||
- **Auto-timeout**: if active warning count >= `autoTimeoutThreshold`, the user is automatically timed out for 24 hours and a separate `TIMEOUT` case is created with `moderatorId: "0"` (system). The timeout target (Discord GuildMember) is passed in from the command layer.
|
||||
- `clearCase` sets `active: false` and records who cleared it and why. It works on any case type, not just warnings.
|
||||
- The service does **not** perform Discord actions (kick, ban, timeout) directly -- it only manages database records. The bot command layer is responsible for calling Discord APIs and then recording cases here. The one exception is auto-timeout in `issueWarning`, where the Discord member object is passed in.
|
||||
- `searchCases` supports pagination via `limit`/`offset` (default limit 50).
|
||||
## Responsibilities
|
||||
|
||||
- create and query moderation case records
|
||||
- manage active warning state
|
||||
- optionally DM warned users
|
||||
- optionally auto-timeout when warning thresholds are reached
|
||||
|
||||
## Main methods
|
||||
|
||||
- `createCase()`
|
||||
- `issueWarning()`
|
||||
- `getCaseById()`
|
||||
- `getUserCases()`
|
||||
- `getUserWarnings()`
|
||||
- `getUserNotes()`
|
||||
- `clearCase()`
|
||||
- `searchCases()`
|
||||
- `getActiveWarningCount()`
|
||||
|
||||
## Notes
|
||||
|
||||
- case IDs are generated in application code as `CASE-0001`, `CASE-0002`, and so on
|
||||
- warnings are the main case type that starts as `active: true`
|
||||
- `issueWarning()` can DM the user and can create a follow-up timeout case when the configured threshold is hit
|
||||
- the service stores moderation records; it does not generally execute Discord actions itself
|
||||
- the auto-timeout path is the exception because a timeout target can be passed into `issueWarning()`
|
||||
|
||||
Reference in New Issue
Block a user