# treymouledoux/regy-bot architecture

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

- Interactive diagram: https://gitdiagram.com/treymouledoux/regy-bot
- Repository: https://github.com/treymouledoux/regy-bot

## Overview

Regy-Bot is a Discord regex-moderation bot. Its main workflow is to receive Discord events, scan or re-scan messages against server rules, then remove violations, track infractions, and notify users or staff. Separate capabilities cover server configuration and staff management, RTI community regex templates, raid detection, and moderation commands. The excerpts show startup dispatch, portions of message handling, and selected utilities; several feature links below are based on README descriptions rather than inspected implementation.

Main entry points: [`src/commands/mod.rs`](https://github.com/treymouledoux/regy-bot/blob/master/src/commands/mod.rs) (Slash command registry), [`src/events/new_message.rs`](https://github.com/treymouledoux/regy-bot/blob/master/src/events/new_message.rs) (Message scanning), [`src/main.rs`](https://github.com/treymouledoux/regy-bot/blob/master/src/main.rs) (Bot startup and dispatch), [`src/utils/config/structs.rs`](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/structs.rs) (Server configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Discord runtime"]
  node_runtime["Bot startup and dispatch<br/>[main.rs]"]
  node_command_registry["Slash command registry<br/>[mod.rs]"]
end

subgraph group_moderation["Moderation"]
  node_message_scan["Message scanning<br/>[new_message.rs]"]
  node_message_update["Edited-message scanning<br/>[update_message.rs]"]
  node_automod["Automod integration"]
  node_infractions["Infraction commands"]
  node_moderation_commands["Moderation commands"]
end

subgraph group_server_admin["Server administration"]
  node_config_commands["Server setup and cloning"]
  node_dead_zone_commands["Dead-zone commands"]
  node_staff_commands["Staff management commands"]
  node_regex_commands["Regex rule commands"]
  node_staff_roles["Staff-role configuration<br/>[mod.rs]"]
  node_legacy_staff["Legacy staff configuration<br/>[legacy.rs]"]
end

subgraph group_features["Bot features"]
  node_rti_commands["RTI search and updates"]
  node_rti_index["RTI package index<br/>[rti.rs]"]
  node_raid_detection["Raid detection &#40;IPM&#41;<br/>[ipm.rs]"]
  node_crc["Compiled regex cache<br/>[crc.rs]"]
  node_logging["Message logging<br/>[new_message.rs]"]
  node_member_events["Member and ban events"]
  node_reactions["Reaction workflows<br/>[reaction_add.rs]"]
end

subgraph group_internal["Configuration and utilities"]
  node_config_store[("Server configuration<br/>[structs.rs]")]
  node_regex_config["Regex rule storage<br/>[regex.rs]"]
  node_dead_zone_config["Dead-zone storage<br/>[dead_zones.rs]"]
  node_infraction_config["Infraction storage<br/>[infractions.rs]"]
  node_config_migration["Configuration migration<br/>[updating.rs]"]
end

node_discord(("Discord"))

node_discord -->|"delivers events"| node_runtime
node_runtime -->|"registers commands"| node_command_registry
node_runtime -->|"dispatches messages"| node_message_scan
node_runtime -->|"dispatches edits"| node_message_update
node_runtime -->|"dispatches actions"| node_automod
node_command_registry -->|"registers commands"| node_infractions
node_command_registry -->|"registers commands"| node_moderation_commands
node_command_registry -->|"registers commands"| node_config_commands
node_command_registry -->|"registers commands"| node_dead_zone_commands
node_command_registry -->|"registers commands"| node_staff_commands
node_command_registry -->|"registers commands"| node_regex_commands
node_command_registry -->|"registers commands"| node_rti_commands
node_message_scan -->|"checks channel"| node_dead_zone_config
node_message_scan -->|"records violations"| node_infraction_config
node_message_update -->|"checks channel"| node_dead_zone_config
node_message_update -->|"records violations"| node_infraction_config
node_message_scan -->|"sends moderation logs"| node_logging
node_message_scan -.->|"updates raid tally"| node_raid_detection
node_message_scan -.->|"uses compiled cache"| node_crc
node_rti_commands -->|"searches packages"| node_rti_index
node_regex_commands -.->|"manages rules"| node_regex_config
node_staff_commands -.->|"manages roles"| node_staff_roles
node_staff_commands -.->|"manages legacy staff"| node_legacy_staff
node_config_commands -.->|"configures server"| node_config_store
node_dead_zone_commands -->|"manages channels"| node_dead_zone_config
node_infraction_config -->|"uses config model"| node_config_store
node_regex_config -->|"uses config model"| node_config_store
node_config_migration -->|"converts configuration"| node_config_store
node_runtime -->|"migrates legacy config"| node_config_migration
node_discord -.->|"sends member events"| node_member_events
node_discord -->|"sends reactions"| node_reactions
node_message_scan -->|"removes violating messages"| node_moderation_commands
node_discord -->|"sends automod events"| node_automod

click node_runtime "https://github.com/treymouledoux/regy-bot/blob/master/src/main.rs"
click node_command_registry "https://github.com/treymouledoux/regy-bot/blob/master/src/commands/mod.rs"
click node_message_scan "https://github.com/treymouledoux/regy-bot/blob/master/src/events/new_message.rs"
click node_message_update "https://github.com/treymouledoux/regy-bot/blob/master/src/events/update_message.rs"
click node_automod "https://github.com/treymouledoux/regy-bot/blob/master/src/events/automod_execution.rs"
click node_infractions "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/infractions"
click node_moderation_commands "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/moderation"
click node_config_commands "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/management"
click node_dead_zone_commands "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/management"
click node_staff_commands "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/management/staff"
click node_regex_commands "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/regex"
click node_staff_roles "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/staff/mod.rs"
click node_legacy_staff "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/staff/legacy.rs"
click node_rti_commands "https://github.com/treymouledoux/regy-bot/tree/master/src/commands/rti"
click node_rti_index "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/rti.rs"
click node_raid_detection "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/ipm.rs"
click node_crc "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/crc.rs"
click node_logging "https://github.com/treymouledoux/regy-bot/blob/master/src/events/new_message.rs"
click node_member_events "https://github.com/treymouledoux/regy-bot/blob/master/src/events/guild_member_join.rs"
click node_reactions "https://github.com/treymouledoux/regy-bot/blob/master/src/events/reaction_add.rs"
click node_config_store "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/structs.rs"
click node_regex_config "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/regex.rs"
click node_dead_zone_config "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/dead_zones.rs"
click node_infraction_config "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/infractions.rs"
click node_config_migration "https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/updating.rs"

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_runtime,node_command_registry toneBlue
class node_message_scan,node_message_update,node_automod,node_infractions,node_moderation_commands toneAmber
class node_config_commands,node_dead_zone_commands,node_staff_commands,node_regex_commands,node_staff_roles,node_legacy_staff toneMint
class node_rti_commands,node_rti_index,node_raid_detection,node_crc,node_logging,node_member_events,node_reactions toneRose
class node_config_store,node_regex_config,node_dead_zone_config,node_infraction_config,node_config_migration,node_discord toneIndigo
```

## Components

### Discord runtime

- [Bot startup and dispatch](https://github.com/treymouledoux/regy-bot/blob/master/src/main.rs): `src/main.rs`
- [Slash command registry](https://github.com/treymouledoux/regy-bot/blob/master/src/commands/mod.rs): `src/commands/mod.rs`

### Moderation

- [Message scanning](https://github.com/treymouledoux/regy-bot/blob/master/src/events/new_message.rs): `src/events/new_message.rs`
- [Edited-message scanning](https://github.com/treymouledoux/regy-bot/blob/master/src/events/update_message.rs): `src/events/update_message.rs`
- [Automod integration](https://github.com/treymouledoux/regy-bot/blob/master/src/events/automod_execution.rs): `src/events/automod_execution.rs`
- [Infraction commands](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/infractions): `src/commands/infractions`
- [Moderation commands](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/moderation): `src/commands/moderation`

### Server administration

- [Server setup and cloning](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/management): `src/commands/management`
- [Dead-zone commands](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/management): `src/commands/management`
- [Staff management commands](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/management/staff): `src/commands/management/staff`
- [Regex rule commands](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/regex): `src/commands/regex`
- [Staff-role configuration](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/staff/mod.rs): `src/utils/config/staff/mod.rs`
- [Legacy staff configuration](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/staff/legacy.rs): `src/utils/config/staff/legacy.rs`

### Bot features

- [RTI search and updates](https://github.com/treymouledoux/regy-bot/tree/master/src/commands/rti): `src/commands/rti`
- [RTI package index](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/rti.rs): `src/utils/rti.rs`
- [Raid detection (IPM)](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/ipm.rs): `src/utils/ipm.rs`
- [Compiled regex cache](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/crc.rs): `src/utils/crc.rs`
- [Message logging](https://github.com/treymouledoux/regy-bot/blob/master/src/events/new_message.rs): `src/events/new_message.rs`
- [Member and ban events](https://github.com/treymouledoux/regy-bot/blob/master/src/events/guild_member_join.rs): `src/events/guild_member_join.rs`
- [Reaction workflows](https://github.com/treymouledoux/regy-bot/blob/master/src/events/reaction_add.rs): `src/events/reaction_add.rs`

### Configuration and utilities

- [Server configuration](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/structs.rs): `src/utils/config/structs.rs`
- [Regex rule storage](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/regex.rs): `src/utils/config/regex.rs`
- [Dead-zone storage](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/dead_zones.rs): `src/utils/config/dead_zones.rs`
- [Infraction storage](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/infractions.rs): `src/utils/config/infractions.rs`
- [Configuration migration](https://github.com/treymouledoux/regy-bot/blob/master/src/utils/config/updating.rs): `src/utils/config/updating.rs`

### Other components

- **Discord**

## Connections

- Discord → Bot startup and dispatch: delivers events (evidence: `src/main.rs`)
- Bot startup and dispatch → Slash command registry: registers commands (evidence: `src/main.rs`)
- Bot startup and dispatch → Message scanning: dispatches messages (evidence: `src/main.rs`)
- Bot startup and dispatch → Edited-message scanning: dispatches edits (evidence: `src/main.rs`)
- Bot startup and dispatch → Automod integration: dispatches actions (evidence: `src/main.rs`)
- Slash command registry → Infraction commands: registers commands (evidence: `src/commands/mod.rs`)
- Slash command registry → Moderation commands: registers commands (evidence: `src/commands/mod.rs`)
- Slash command registry → Server setup and cloning: registers commands (evidence: `src/commands/mod.rs`)
- Slash command registry → Dead-zone commands: registers commands (evidence: `src/commands/mod.rs`)
- Slash command registry → Staff management commands: registers commands (evidence: `src/commands/mod.rs`)
- Slash command registry → Regex rule commands: registers commands (evidence: `src/commands/mod.rs`)
- Slash command registry → RTI search and updates: registers commands (evidence: `src/commands/mod.rs`)
- Message scanning → Dead-zone storage: checks channel (evidence: `src/events/new_message.rs`)
- Message scanning → Infraction storage: records violations (evidence: `src/events/new_message.rs`)
- Edited-message scanning → Dead-zone storage: checks channel (evidence: `src/events/update_message.rs`)
- Edited-message scanning → Infraction storage: records violations (evidence: `src/events/update_message.rs`)
- Message scanning → Message logging: sends moderation logs (evidence: `README.md`)
- Message scanning → Raid detection (IPM): updates raid tally
- Message scanning → Compiled regex cache: uses compiled cache
- RTI search and updates → RTI package index: searches packages (evidence: `src/commands/rti/mod.rs`)
- Regex rule commands → Regex rule storage: manages rules
- Staff management commands → Staff-role configuration: manages roles
- Staff management commands → Legacy staff configuration: manages legacy staff
- Server setup and cloning → Server configuration: configures server
- Dead-zone commands → Dead-zone storage: manages channels (evidence: `src/commands/management/remove_dead_zone.rs`)
- Infraction storage → Server configuration: uses config model (evidence: `src/utils/config/infractions.rs`)
- Regex rule storage → Server configuration: uses config model (evidence: `src/utils/config/regex.rs`)
- Configuration migration → Server configuration: converts configuration (evidence: `src/utils/config/updating.rs`)
- Bot startup and dispatch → Configuration migration: migrates legacy config (evidence: `src/main.rs`)
- Discord → Member and ban events: sends member events (evidence: `README.md`)
- Discord → Reaction workflows: sends reactions
- Message scanning → Moderation commands: removes violating messages (evidence: `README.md`)
- Discord → Automod integration: sends automod events
