# astromni/discord-stylebot architecture

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

- Interactive diagram: https://gitdiagram.com/astromni/discord-stylebot
- Repository: https://github.com/astromni/discord-stylebot

## Overview

AutoPlate is a small event-driven Discord bot: it reads a bot token and fixed style settings, connects directly to Discord’s Gateway, and applies the configured nameplate to itself after a guild-create event. The runtime and its distinct protocol, event, and REST responsibilities all live in `index.js`; the graph separates them to show the workflow. The source excerpt supports these calls and transfers; setup and style options are documented in the README.

Main entry points: [`index.js`](https://github.com/astromni/discord-stylebot/blob/main/index.js) (Gateway connection), [`config.json`](https://github.com/astromni/discord-stylebot/blob/main/config.json) (Bot token)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Configuration"]
  node_token["Bot token<br/>[config.json]"]
  node_style["Style settings<br/>[index.js]"]
end

subgraph group_runtime["Bot runtime"]
  node_gateway_client["Gateway connection<br/>[index.js]"]
  node_protocol["Identify and heartbeat<br/>[index.js]"]
  node_event_handler["Gateway event handler<br/>[index.js]"]
  node_join_delay["Join delay<br/>[index.js]"]
  node_nameplate_request["Nameplate update<br/>[index.js]"]
end

subgraph group_discord["Discord services"]
  node_gateway_service["Discord Gateway"]
  node_discord_api["Discord API"]
end

node_operator(("Bot operator"))

node_operator -->|"sets token"| node_token
node_token -->|"provides credentials"| node_gateway_client
node_style -->|"configures update"| node_nameplate_request
node_gateway_client -->|"opens WebSocket"| node_gateway_service
node_gateway_service -->|"delivers events"| node_event_handler
node_gateway_client -->|"handles opcodes"| node_protocol
node_protocol -->|"identifies and heartbeats"| node_gateway_service
node_event_handler -->|"schedules on join"| node_join_delay
node_join_delay -->|"invokes after delay"| node_nameplate_request
node_nameplate_request -->|"PATCHes member"| node_discord_api

click node_token "https://github.com/astromni/discord-stylebot/blob/main/config.json"
click node_style "https://github.com/astromni/discord-stylebot/blob/main/index.js"
click node_gateway_client "https://github.com/astromni/discord-stylebot/blob/main/index.js"
click node_protocol "https://github.com/astromni/discord-stylebot/blob/main/index.js"
click node_event_handler "https://github.com/astromni/discord-stylebot/blob/main/index.js"
click node_join_delay "https://github.com/astromni/discord-stylebot/blob/main/index.js"
click node_nameplate_request "https://github.com/astromni/discord-stylebot/blob/main/index.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_token,node_style toneBlue
class node_gateway_client,node_protocol,node_event_handler,node_join_delay,node_nameplate_request toneAmber
class node_gateway_service,node_discord_api toneMint
class node_operator toneIndigo
```

## Components

### Configuration

- [Bot token](https://github.com/astromni/discord-stylebot/blob/main/config.json): `config.json`
- [Style settings](https://github.com/astromni/discord-stylebot/blob/main/index.js): `index.js`

### Bot runtime

- [Gateway connection](https://github.com/astromni/discord-stylebot/blob/main/index.js): `index.js`
- [Identify and heartbeat](https://github.com/astromni/discord-stylebot/blob/main/index.js): `index.js`
- [Gateway event handler](https://github.com/astromni/discord-stylebot/blob/main/index.js): `index.js`
- [Join delay](https://github.com/astromni/discord-stylebot/blob/main/index.js): `index.js`
- [Nameplate update](https://github.com/astromni/discord-stylebot/blob/main/index.js): `index.js`

### Discord services

- **Discord Gateway**
- **Discord API**

### Other components

- **Bot operator**

## Connections

- Bot operator → Bot token: sets token (evidence: `README.md`)
- Bot token → Gateway connection: provides credentials (evidence: `index.js`)
- Style settings → Nameplate update: configures update (evidence: `index.js`)
- Gateway connection → Discord Gateway: opens WebSocket (evidence: `index.js`)
- Discord Gateway → Gateway event handler: delivers events (evidence: `index.js`)
- Gateway connection → Identify and heartbeat: handles opcodes (evidence: `index.js`)
- Identify and heartbeat → Discord Gateway: identifies and heartbeats (evidence: `index.js`)
- Gateway event handler → Join delay: schedules on join (evidence: `index.js`)
- Join delay → Nameplate update: invokes after delay (evidence: `index.js`)
- Nameplate update → Discord API: PATCHes member (evidence: `index.js`)
