Cache-first Discord security bot backed by MariaDB. Built on discord.js v14 with audit-log-aware automation for anti-abuse workloads.
Designed for guarding one guild or a small handful; cross-shard scale requires intentional sharding and per-shard pools.
- Cache-first reads — guild settings live in RAM; MariaDB persists asynchronously.
- Audit-driven routing —
GuildAuditLogEntryCreatecatches fast webhook/integration paths. - Modular interception — channels, roles, webhooks, vanity, bots, bans toggled independently.
- Sanctions —
ban/kick/stripwith explicit outcomes (protected,forbidden, …). - Snapshots — backup and restore guild layout with rate-limit aware spacing.
- Vanity safeguards — only the Discord-transfer guild owner may change vanity; env owner list is ignored for vanity.
- Operational polish — per-guild settings mutexes, bounded discord.js caches, batched audit logs.
npm installCopy .env.example to .env and populate secrets (DISCORD_TOKEN, CLIENT_ID, OWNER_ID, database connection, …).
Apply schema:
npm run db:initRegister slash commands:
npm run deployRun:
npm start # production
npm run dev # node --watchWhen COMMAND_ALLOWED_USER_IDS is populated, slash commands default to hidden (setDefaultMemberPermissions('0')); finalize visibility inside Server Settings → Integrations and rely on runtime checks as a second barrier.
| Command | Purpose |
|---|---|
/config show |
Status: modules, thresholds, ledger size, websocket ping |
/config toggle |
Toggle a guard module |
/config punishment |
Default sanction mode |
/config threshold |
Rapid-action window tuning |
/config enable |
Master toggle |
/snapshot create/list/restore/delete |
Structural backups |
src/
index.js # bootstrap & process lifecycle
config.js # env validation
structures/ # Guard client + MariaDB facade
handlers/ # dynamic command/event loaders
events/ # gateway listeners
utils/ # permissions, sanctioning, auditing helpers
schema.sql # DDL
npm run lint
npm run lint:fix- Rotate leaked tokens promptly and scrub git history when needed.
- Grant the bot minimal permissions (Manage Channels/Roles/Webhooks, Ban, Kick, View Audit Log rather than Administrator when possible).
- Scope database grants to explicit DML privileges for the deployment database only.
- Stream logs with
LOG_FORMAT=jsoninto your observability stack.
MIT