# corwindev/discord-bot architecture

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

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

## Overview

Discord-Bot is a multi-purpose Discord.js bot. A member invokes a slash command or interacts with the bot in a server; the bot handles commands and events to deliver moderation, community-management, entertainment, and utility features. MongoDB backs persistent server and user data, while music uses a Lavalink-backed player. The README documents the major capabilities; source excerpts show startup, message and invite event behavior, and giveaway persistence. Many command implementations and their dispatch wiring were not sampled, so those feature links are documented rather than inferred from imports.

Main entry points: [`src/interactions/Command`](https://github.com/corwindev/discord-bot/tree/main/src/interactions/Command) (Command handling), [`src/bot.js`](https://github.com/corwindev/discord-bot/blob/main/src/bot.js) (Audio player), [`src/events/invite/inviteJoin.js`](https://github.com/corwindev/discord-bot/blob/main/src/events/invite/inviteJoin.js) (Invite tracking), [`src/events/message/messageCreate.js`](https://github.com/corwindev/discord-bot/blob/main/src/events/message/messageCreate.js) (Levels and messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bot["Bot client<br/>[bot.js]"]
  node_command_dispatch["Command handling"]
  node_event_processing["Event processing"]
end

subgraph group_community["Server community"]
  node_moderation["Moderation and automod"]
  node_tickets["Tickets and setup"]
  node_server_tools["Server configuration"]
  node_invites["Invite tracking<br/>[inviteJoin.js]"]
end

subgraph group_engagement["Engagement features"]
  node_levels_messages["Levels and messages<br/>[messageCreate.js]"]
  node_giveaways["Giveaway management<br/>[Manager.js]"]
  node_games_economy["Games and economy"]
  node_social_features["Social features"]
end

subgraph group_media["Audio and media"]
  node_music_commands["Music commands"]
  node_radio_commands["Radio commands"]
  node_player["Audio player<br/>[bot.js]"]
  node_track_announcement["Track announcements<br/>[trackStart.js]"]
end

subgraph group_persistence["Persistence"]
  node_database_connection["MongoDB connection<br/>[connect.js]"]
  node_models[("MongoDB models")]
  node_giveaway_model[("Giveaway records<br/>[giveaways.js]")]
end

node_member(("Discord member"))
node_mongodb[("MongoDB service")]
node_lavalink["Lavalink service"]

node_member -.->|"invokes commands"| node_command_dispatch
node_command_dispatch -.->|"offers moderation"| node_moderation
node_command_dispatch -.->|"offers tickets"| node_tickets
node_command_dispatch -.->|"offers customization"| node_server_tools
node_command_dispatch -.->|"offers invite tools"| node_invites
node_command_dispatch -.->|"offers leveling"| node_levels_messages
node_command_dispatch -.->|"offers giveaways"| node_giveaways
node_command_dispatch -.->|"offers games"| node_games_economy
node_command_dispatch -.->|"offers suggestions"| node_social_features
node_command_dispatch -.->|"offers music"| node_music_commands
node_command_dispatch -.->|"offers radio"| node_radio_commands
node_bot -->|"connects"| node_database_connection
node_database_connection -->|"opens connection"| node_mongodb
node_event_processing -->|"handles messages"| node_levels_messages
node_levels_messages -->|"reads and updates"| node_models
node_event_processing -->|"handles invite joins"| node_invites
node_invites -->|"reads and writes"| node_models
node_bot -->|"configures player"| node_player
node_player -->|"connects audio"| node_lavalink
node_music_commands -.->|"controls playback"| node_player
node_player -.->|"announces tracks"| node_track_announcement
node_giveaways -->|"persists records"| node_giveaway_model
node_giveaway_model -.->|"stores giveaway data"| node_models

click node_bot "https://github.com/corwindev/discord-bot/blob/main/src/bot.js"
click node_command_dispatch "https://github.com/corwindev/discord-bot/tree/main/src/interactions/Command"
click node_event_processing "https://github.com/corwindev/discord-bot/tree/main/src/events"
click node_moderation "https://github.com/corwindev/discord-bot/tree/main/src/commands/moderation"
click node_tickets "https://github.com/corwindev/discord-bot/tree/main/src/commands/tickets"
click node_server_tools "https://github.com/corwindev/discord-bot/tree/main/src/commands/setup"
click node_invites "https://github.com/corwindev/discord-bot/blob/main/src/events/invite/inviteJoin.js"
click node_levels_messages "https://github.com/corwindev/discord-bot/blob/main/src/events/message/messageCreate.js"
click node_giveaways "https://github.com/corwindev/discord-bot/blob/main/src/packages/discord-giveaways/src/Manager.js"
click node_games_economy "https://github.com/corwindev/discord-bot/tree/main/src/commands/economy"
click node_social_features "https://github.com/corwindev/discord-bot/tree/main/src/commands/suggestions"
click node_music_commands "https://github.com/corwindev/discord-bot/tree/main/src/commands/music"
click node_radio_commands "https://github.com/corwindev/discord-bot/tree/main/src/commands/radio"
click node_player "https://github.com/corwindev/discord-bot/blob/main/src/bot.js"
click node_track_announcement "https://github.com/corwindev/discord-bot/blob/main/src/music/trackStart.js"
click node_database_connection "https://github.com/corwindev/discord-bot/blob/main/src/database/connect.js"
click node_models "https://github.com/corwindev/discord-bot/tree/main/src/database/models"
click node_giveaway_model "https://github.com/corwindev/discord-bot/blob/main/src/database/models/giveaways.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_bot,node_command_dispatch,node_event_processing toneBlue
class node_moderation,node_tickets,node_server_tools,node_invites,node_mongodb toneAmber
class node_levels_messages,node_giveaways,node_games_economy,node_social_features toneMint
class node_music_commands,node_radio_commands,node_player,node_track_announcement toneRose
class node_database_connection,node_models,node_giveaway_model,node_member,node_lavalink toneIndigo
```

## Components

### Bot runtime

- [Bot client](https://github.com/corwindev/discord-bot/blob/main/src/bot.js): `src/bot.js`
- [Command handling](https://github.com/corwindev/discord-bot/tree/main/src/interactions/Command): `src/interactions/Command`
- [Event processing](https://github.com/corwindev/discord-bot/tree/main/src/events): `src/events`

### Server community

- [Moderation and automod](https://github.com/corwindev/discord-bot/tree/main/src/commands/moderation): `src/commands/moderation`
- [Tickets and setup](https://github.com/corwindev/discord-bot/tree/main/src/commands/tickets): `src/commands/tickets`
- [Server configuration](https://github.com/corwindev/discord-bot/tree/main/src/commands/setup): `src/commands/setup`
- [Invite tracking](https://github.com/corwindev/discord-bot/blob/main/src/events/invite/inviteJoin.js): `src/events/invite/inviteJoin.js`

### Engagement features

- [Levels and messages](https://github.com/corwindev/discord-bot/blob/main/src/events/message/messageCreate.js): `src/events/message/messageCreate.js`
- [Giveaway management](https://github.com/corwindev/discord-bot/blob/main/src/packages/discord-giveaways/src/Manager.js): `src/packages/discord-giveaways/src/Manager.js`
- [Games and economy](https://github.com/corwindev/discord-bot/tree/main/src/commands/economy): `src/commands/economy`
- [Social features](https://github.com/corwindev/discord-bot/tree/main/src/commands/suggestions): `src/commands/suggestions`

### Audio and media

- [Music commands](https://github.com/corwindev/discord-bot/tree/main/src/commands/music): `src/commands/music`
- [Radio commands](https://github.com/corwindev/discord-bot/tree/main/src/commands/radio): `src/commands/radio`
- [Audio player](https://github.com/corwindev/discord-bot/blob/main/src/bot.js): `src/bot.js`
- [Track announcements](https://github.com/corwindev/discord-bot/blob/main/src/music/trackStart.js): `src/music/trackStart.js`

### Persistence

- [MongoDB connection](https://github.com/corwindev/discord-bot/blob/main/src/database/connect.js): `src/database/connect.js`
- [MongoDB models](https://github.com/corwindev/discord-bot/tree/main/src/database/models): `src/database/models`
- [Giveaway records](https://github.com/corwindev/discord-bot/blob/main/src/database/models/giveaways.js): `src/database/models/giveaways.js`

### Other components

- **Discord member**
- **MongoDB service**
- **Lavalink service**

## Connections

- Discord member → Command handling: invokes commands
- Command handling → Moderation and automod: offers moderation
- Command handling → Tickets and setup: offers tickets
- Command handling → Server configuration: offers customization
- Command handling → Invite tracking: offers invite tools
- Command handling → Levels and messages: offers leveling
- Command handling → Giveaway management: offers giveaways
- Command handling → Games and economy: offers games
- Command handling → Social features: offers suggestions
- Command handling → Music commands: offers music
- Command handling → Radio commands: offers radio
- Bot client → MongoDB connection: connects (evidence: `src/bot.js`)
- MongoDB connection → MongoDB service: opens connection (evidence: `src/database/connect.js`)
- Event processing → Levels and messages: handles messages (evidence: `src/events/message/messageCreate.js`)
- Levels and messages → MongoDB models: reads and updates (evidence: `src/events/message/messageCreate.js`)
- Event processing → Invite tracking: handles invite joins (evidence: `src/events/invite/inviteJoin.js`)
- Invite tracking → MongoDB models: reads and writes (evidence: `src/events/invite/inviteJoin.js`)
- Bot client → Audio player: configures player (evidence: `src/bot.js`)
- Audio player → Lavalink service: connects audio (evidence: `src/bot.js`)
- Music commands → Audio player: controls playback
- Audio player → Track announcements: announces tracks (evidence: `src/bot.js`)
- Giveaway management → Giveaway records: persists records (evidence: `src/packages/discord-giveaways/src/Manager.js`)
- Giveaway records → MongoDB models: stores giveaway data
