# macho25/discord-bot architecture

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

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

## Overview

This repository is a small Discord bot for managing a Minecraft server on a separate PC. Users issue commands in Discord; the bot checks start limits and server state, then starts or stops the server through its lifecycle logic and remote scripts. A local JSON file persists daily start counts. The excerpts show these responsibilities concentrated in mcbot.py, with logging implemented separately in logger.py. Some lifecycle details are omitted, so the graph avoids asserting the unseen wiring.

Main entry points: [`mcbot.py`](https://github.com/macho25/discord-bot/blob/main/mcbot.py) (Server lifecycle), [`logger.py`](https://github.com/macho25/discord-bot/blob/main/logger.py) (Logger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Discord interaction"]
  node_commands["Command handling<br/>[mcbot.py]"]
  node_policy["Start limit checks<br/>[mcbot.py]"]
end

subgraph group_server["Server operations"]
  node_lifecycle["Server lifecycle<br/>[mcbot.py]"]
  node_remote["SSH script runner<br/>[mcbot.py]"]
  node_wol["Wake-on-LAN<br/>[mcbot.py]"]
  node_rcon["Minecraft RCON<br/>[mcbot.py]"]
end

subgraph group_support["Persistence and logging"]
  node_counts[("Daily start counts<br/>[mcbot.py]")]
  node_logger["Logger<br/>[logger.py]"]
end

node_user(("Discord user"))
node_discord["Discord platform"]
node_host["Server PC"]
node_minecraft["Minecraft server"]

node_user -->|"sends commands"| node_discord
node_discord -->|"dispatches messages"| node_commands
node_commands -->|"checks limits"| node_policy
node_policy -->|"reads and writes"| node_counts
node_commands -->|"checks and controls"| node_lifecycle
node_lifecycle -->|"sends wake packet"| node_wol
node_wol -->|"wakes"| node_host
node_lifecycle -->|"runs scripts"| node_remote
node_remote -->|"executes remotely"| node_host
node_lifecycle -->|"sends commands"| node_rcon
node_rcon -->|"controls"| node_minecraft
node_commands -->|"sends replies"| node_discord
node_lifecycle -->|"logs events"| node_logger
node_policy -->|"logs events"| node_logger

click node_commands "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_policy "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_lifecycle "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_remote "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_wol "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_rcon "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_counts "https://github.com/macho25/discord-bot/blob/main/mcbot.py"
click node_logger "https://github.com/macho25/discord-bot/blob/main/logger.py"

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_commands,node_policy,node_user toneBlue
class node_lifecycle,node_remote,node_wol,node_rcon toneAmber
class node_counts,node_logger,node_host,node_minecraft toneMint
class node_discord toneIndigo
```

## Components

### Discord interaction

- [Command handling](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`
- [Start limit checks](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`

### Server operations

- [Server lifecycle](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`
- [SSH script runner](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`
- [Wake-on-LAN](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`
- [Minecraft RCON](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`

### Persistence and logging

- [Daily start counts](https://github.com/macho25/discord-bot/blob/main/mcbot.py): `mcbot.py`
- [Logger](https://github.com/macho25/discord-bot/blob/main/logger.py): `logger.py`

### Other components

- **Discord user**
- **Discord platform**
- **Server PC**
- **Minecraft server**

## Connections

- Discord user → Discord platform: sends commands
- Discord platform → Command handling: dispatches messages
- Command handling → Start limit checks: checks limits
- Start limit checks → Daily start counts: reads and writes
- Command handling → Server lifecycle: checks and controls
- Server lifecycle → Wake-on-LAN: sends wake packet
- Wake-on-LAN → Server PC: wakes
- Server lifecycle → SSH script runner: runs scripts
- SSH script runner → Server PC: executes remotely
- Server lifecycle → Minecraft RCON: sends commands
- Minecraft RCON → Minecraft server: controls
- Command handling → Discord platform: sends replies
- Server lifecycle → Logger: logs events
- Start limit checks → Logger: logs events
