fix: add discord mention context history

This commit is contained in:
Peter Steinberger
2026-01-01 23:58:35 +01:00
parent 06e379a239
commit 38d8a669b4
6 changed files with 69 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ Status: ready for DM and guild text channels via the official Discord bot gatewa
6. Guild channels: use `channel:<channelId>` for delivery. Mentions are required by default; disable with `discord.requireMention = false`.
7. Optional DM allowlist: reuse `discord.allowFrom` with user ids (`1234567890` or `discord:1234567890`). Use `"*"` to allow all DMs.
8. Optional guild allowlist: set `discord.guildAllowFrom` with `guilds` and/or `users` to gate who can invoke the bot in servers.
9. Optional guild context history: set `discord.historyLimit` (default 20) to include the last N guild messages as context when replying to a mention. Set `0` to disable.
Note: Discord does not provide a simple username → id lookup without extra guild context, so prefer ids or `<@id>` mentions for DM delivery targets.
@@ -45,7 +46,8 @@ Note: Discord does not provide a simple username → id lookup without extra gui
users: ["987654321098765432"]
},
requireMention: true,
mediaMaxMb: 8
mediaMaxMb: 8,
historyLimit: 20
}
}
```
@@ -54,6 +56,7 @@ Note: Discord does not provide a simple username → id lookup without extra gui
- `guildAllowFrom`: Optional allowlist for guild messages. Set `guilds` and/or `users` (ids). When both are set, both must match.
- `requireMention`: when `true`, messages in guild channels must mention the bot.
- `mediaMaxMb`: clamp inbound media saved to disk.
- `historyLimit`: number of recent guild messages to include as context when replying to a mention (default 20, `0` disables).
## Safety & ops
- Treat the bot token like a password; prefer the `DISCORD_BOT_TOKEN` env var on supervised hosts or lock down the config file permissions.