Skip to content

feat: add Discord AI agent with admin panel configuration#626

Draft
garrappachc wants to merge 1 commit into
masterfrom
feat/discord-ai-agent
Draft

feat: add Discord AI agent with admin panel configuration#626
garrappachc wants to merge 1 commit into
masterfrom
feat/discord-ai-agent

Conversation

@garrappachc
Copy link
Copy Markdown
Member

Summary

  • Adds a Claude-powered AI agent that answers player and admin questions in Discord by querying MongoDB
  • Agent core lives in src/agent/ (session management, query execution, system prompt) — interface-agnostic so new adapters (Slack, web chat, etc.) can be added without touching the core
  • Discord adapter auto-loaded as a Fastify plugin; silently disabled when DISCORD_BOT_TOKEN or ANTHROPIC_API_KEY are missing
  • CLI adapter at agent/cli.ts (pnpm agent:cli) for local testing without Discord
  • Admin panel Discord page extended with agent status (enabled/disabled + reasons) and per-guild channel selection

What the agent can do

  • Answer natural language questions about players, games, and stats by generating and executing MongoDB queries
  • Handles DPM, K/D, HPM (medic), game history, player lookups, map stats, etc.
  • Responds in the language of the question (Polish, English, etc.)
  • Pushes back on vulgar or off-topic messages with a dry dismissal
  • Links players and games back to the website
  • Per-channel enable/disable — only responds where configured

Configuration required

  • ANTHROPIC_API_KEY env var (new, optional — agent disabled if absent)
  • Discord bot must have Message Content Intent and Server Members Intent enabled in the Discord developer portal
  • Enable agent per-channel in Admin → Discord → guild config

Test plan

  • pnpm agent:cli starts a REPL and answers questions against the DB
  • Agent responds to @mentions only in configured channels
  • Agent is silent in unconfigured channels
  • Admin panel shows "Agent enabled" when both keys are set and Discord is connected
  • Admin panel shows specific missing-key reason(s) when disabled
  • Channel multi-select saves and reloads correctly
  • Saving guild config with no channels selected clears agent access for that guild
  • Vulgar messages get a dismissal, not a DB query

🤖 Generated with Claude Code

- Agent core in src/agent/ (create-session, execute-query, system-prompt)
- Discord plugin auto-loaded at startup; no-ops when keys are missing
- CLI entrypoint at agent/cli.ts for local testing (pnpm agent:cli)
- Admin panel shows agent enabled/disabled status with reasons
- Per-guild agent channel selection via multi-select in Discord config
- agent.channels configuration key stores enabled guild+channel pairs
- Fix pre-existing bug in set-multi.ts (missing $set operator + events)
- Requires ANTHROPIC_API_KEY env var and MessageContent/GuildMembers Discord intents

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Playwright test results

passed  199 passed

Details

stats  199 tests across 29 suites
duration  11 minutes, 33 seconds
commit  6758820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant