# bloushi52/paldefender-discord-bot architecture

> Architecture diagram of the GitHub repository bloushi52/paldefender-discord-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bloushi52/paldefender-discord-bot
- Repository: https://github.com/bloushi52/paldefender-discord-bot

## Overview

PalDefender Discord Bot is a self-hosted bridge: authorized Discord guild users invoke ephemeral slash commands, which call PalDefender’s REST API and return formatted results or errors. Configuration sets credentials, access rules, branding, and safety limits. Command registration and the doctor check are separate operational capabilities. The graph follows shown imports and calls; broader command coverage and deployment behavior are included where the README documents them, without assuming unsampled implementation details.

Main entry points: [`src/api.js`](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/api.js) (REST API client), [`src/commands.js`](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js) (Slash commands), [`src/index.js`](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/index.js) (Bot entry point), [`src/deploy-commands.js`](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/deploy-commands.js) (Command registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Discord interactions"]
  node_authorization["Guild authorization<br/>[authorization.js]"]
  node_command_handlers["Slash commands<br/>[commands.js]"]
  node_server_commands["Server commands<br/>[commands.js]"]
  node_player_commands["Player commands<br/>[commands.js]"]
  node_moderation_commands["Moderation commands<br/>[commands.js]"]
  node_grant_commands["Give commands<br/>[commands.js]"]
  node_technology_commands["Technology commands<br/>[commands.js]"]
  node_guild_commands["Guild commands<br/>[commands.js]"]
end

subgraph group_bridge["Bot bridge"]
  node_entry["Bot entry point<br/>[index.js]"]
  node_configuration["Configuration<br/>[config.js]"]
  node_api_client["REST API client<br/>[api.js]"]
  node_reply_format["Reply formatting<br/>[response.js]"]
  node_safety_limits["Response limits<br/>[limits.js]"]
end

subgraph group_operations["Setup and checks"]
  node_registration["Command registration<br/>[deploy-commands.js]"]
  node_doctor["Connectivity check<br/>[doctor.js]"]
end

subgraph group_external["External services"]
  node_discord(("Discord platform"))
  node_paldefender(("PalDefender REST API"))
end

node_operator(("Guild administrator"))

node_operator -->|"invokes commands"| node_discord
node_discord -->|"delivers interactions"| node_entry
node_entry -->|"loads settings"| node_configuration
node_entry -->|"checks access"| node_authorization
node_entry -->|"dispatches commands"| node_command_handlers
node_entry -->|"formats replies"| node_reply_format
node_server_commands -->|"calls endpoints"| node_api_client
node_player_commands -->|"calls endpoints"| node_api_client
node_technology_commands -->|"calls endpoints"| node_api_client
node_guild_commands -->|"calls endpoints"| node_api_client
node_moderation_commands -.->|"calls endpoints"| node_api_client
node_grant_commands -.->|"calls endpoints"| node_api_client
node_command_handlers -.->|"includes command group"| node_server_commands
node_command_handlers -.->|"includes command group"| node_player_commands
node_command_handlers -.->|"includes command group"| node_moderation_commands
node_command_handlers -.->|"includes command group"| node_grant_commands
node_command_handlers -.->|"includes command group"| node_technology_commands
node_command_handlers -.->|"includes command group"| node_guild_commands
node_api_client -->|"sends REST requests"| node_paldefender
node_api_client -->|"limits responses"| node_safety_limits
node_reply_format -->|"caps attachments"| node_safety_limits
node_reply_format -->|"returns ephemeral output"| node_discord
node_registration -->|"loads settings"| node_configuration
node_registration -->|"registers commands"| node_command_handlers
node_registration -->|"updates guild commands"| node_discord
node_doctor -->|"loads settings"| node_configuration
node_doctor -->|"checks connectivity"| node_api_client
node_api_client -->|"checks version"| node_paldefender

click node_entry "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/index.js"
click node_configuration "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/config.js"
click node_authorization "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/authorization.js"
click node_command_handlers "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_server_commands "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_player_commands "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_moderation_commands "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_grant_commands "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_technology_commands "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_guild_commands "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js"
click node_api_client "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/api.js"
click node_reply_format "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/response.js"
click node_safety_limits "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/limits.js"
click node_registration "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/deploy-commands.js"
click node_doctor "https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/doctor.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authorization,node_command_handlers,node_server_commands,node_player_commands,node_moderation_commands,node_grant_commands,node_technology_commands,node_guild_commands toneBlue
class node_entry,node_configuration,node_api_client,node_reply_format,node_safety_limits toneAmber
class node_registration,node_doctor toneMint
class node_discord,node_paldefender toneRose
class node_operator toneIndigo
```

## Components

### Discord interactions

- [Guild authorization](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/authorization.js): `src/authorization.js`
- [Slash commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`
- [Server commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`
- [Player commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`
- [Moderation commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`
- [Give commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`
- [Technology commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`
- [Guild commands](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/commands.js): `src/commands.js`

### Bot bridge

- [Bot entry point](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/index.js): `src/index.js`
- [Configuration](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/config.js): `src/config.js`
- [REST API client](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/api.js): `src/api.js`
- [Reply formatting](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/response.js): `src/response.js`
- [Response limits](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/limits.js): `src/limits.js`

### Setup and checks

- [Command registration](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/deploy-commands.js): `src/deploy-commands.js`
- [Connectivity check](https://github.com/bloushi52/paldefender-discord-bot/blob/main/src/doctor.js): `src/doctor.js`

### External services

- **Discord platform**
- **PalDefender REST API**

### Other components

- **Guild administrator**

## Connections

- Guild administrator → Discord platform: invokes commands (evidence: `README.md`)
- Discord platform → Bot entry point: delivers interactions (evidence: `src/index.js`)
- Bot entry point → Configuration: loads settings (evidence: `src/index.js`)
- Bot entry point → Guild authorization: checks access (evidence: `src/index.js`)
- Bot entry point → Slash commands: dispatches commands (evidence: `src/index.js`)
- Bot entry point → Reply formatting: formats replies (evidence: `src/index.js`)
- Server commands → REST API client: calls endpoints (evidence: `src/commands.js`)
- Player commands → REST API client: calls endpoints (evidence: `src/commands.js`)
- Technology commands → REST API client: calls endpoints (evidence: `src/commands.js`)
- Guild commands → REST API client: calls endpoints (evidence: `src/commands.js`)
- Moderation commands → REST API client: calls endpoints
- Give commands → REST API client: calls endpoints
- Slash commands → Server commands: includes command group (evidence: `src/commands.js`)
- Slash commands → Player commands: includes command group (evidence: `src/commands.js`)
- Slash commands → Moderation commands: includes command group (evidence: `src/commands.js`)
- Slash commands → Give commands: includes command group (evidence: `src/commands.js`)
- Slash commands → Technology commands: includes command group (evidence: `src/commands.js`)
- Slash commands → Guild commands: includes command group (evidence: `src/commands.js`)
- REST API client → PalDefender REST API: sends REST requests (evidence: `README.md`)
- REST API client → Response limits: limits responses (evidence: `src/api.js`)
- Reply formatting → Response limits: caps attachments (evidence: `src/response.js`)
- Reply formatting → Discord platform: returns ephemeral output (evidence: `README.md`)
- Command registration → Configuration: loads settings (evidence: `src/deploy-commands.js`)
- Command registration → Slash commands: registers commands (evidence: `src/deploy-commands.js`)
- Command registration → Discord platform: updates guild commands (evidence: `src/deploy-commands.js`)
- Connectivity check → Configuration: loads settings (evidence: `src/doctor.js`)
- Connectivity check → REST API client: checks connectivity (evidence: `src/doctor.js`)
- REST API client → PalDefender REST API: checks version
