# syihabudin081/tapir-bot architecture

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

- Interactive diagram: https://gitdiagram.com/syihabudin081/tapir-bot
- Repository: https://github.com/syihabudin081/tapir-bot

## Overview

This is a Discord bot combining music playback, AI-generated social responses, and utility commands. Users send prefix commands in Discord; the event handler parses them and dispatches the matching command. Music playback creates a player, resolves a track through Lavalink, and queues or plays it; social commands can request text from OpenAI and reply in Discord. Startup initializes Discord and the Lavalink clients, then loads commands and events after a node is ready. README-documented commands are included, but unsampled command implementations and their detailed internal calls are not inferred.

Main entry points: [`src/handlers/eventHandler.ts`](https://github.com/syihabudin081/tapir-bot/blob/main/src/handlers/eventHandler.ts) (Event and prefix routing), [`src/index.ts`](https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts) (Startup and clients), [`src/commands/play.ts`](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/play.ts) (Play command), [`src/commands/compliment.ts`](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/compliment.ts) (Compliment command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_main["Startup and clients<br/>[index.ts]"]
  node_commands_loader["Command loader<br/>[commandHandler.ts]"]
  node_events["Event and prefix routing<br/>[eventHandler.ts]"]
  node_interactions["Interaction routing"]
  node_logger["Logging<br/>[logger.ts]"]
end

subgraph group_music["Music playback"]
  node_kazagumo["Player and queue client<br/>[index.ts]"]
  node_shoukaku["Lavalink client<br/>[index.ts]"]
  node_play["Play command<br/>[play.ts]"]
  node_queue["Queue command<br/>[queue.ts]"]
  node_skip["Skip command<br/>[skip.ts]"]
  node_stop["Stop command<br/>[stop.ts]"]
end

subgraph group_social["Social commands"]
  node_compliment["Compliment command<br/>[compliment.ts]"]
  node_roast["Roast command<br/>[roast.ts]"]
  node_hug["Hug command<br/>[hug.ts]"]
  node_kiss["Kiss command<br/>[kiss.ts]"]
end

subgraph group_utility["Utility commands"]
  node_ping["Ping command<br/>[ping.ts]"]
  node_debug["Debug command<br/>[debug.ts]"]
end

node_user(("Discord user"))
node_discord(("Discord"))
node_lavalink["Lavalink server"]
node_openai["OpenAI API"]
node_giphy["GIF media"]

node_main -->|"loads commands"| node_commands_loader
node_main -->|"loads events"| node_events
node_main -->|"initializes"| node_shoukaku
node_main -->|"initializes"| node_openai
node_main -->|"logs through"| node_logger
node_shoukaku -->|"connects to"| node_lavalink
node_events -->|"registers listeners"| node_discord
node_user -->|"sends commands"| node_discord
node_discord -->|"delivers messages"| node_events
node_events -->|"dispatches"| node_play
node_events -->|"dispatches"| node_queue
node_events -->|"dispatches"| node_skip
node_events -->|"dispatches"| node_stop
node_events -->|"dispatches"| node_compliment
node_events -->|"dispatches"| node_roast
node_events -->|"dispatches"| node_hug
node_events -->|"dispatches"| node_kiss
node_events -->|"dispatches"| node_ping
node_events -->|"dispatches"| node_debug
node_events -->|"registers"| node_interactions
node_interactions -->|"handles interactions"| node_discord
node_play -->|"creates player"| node_kazagumo
node_play -->|"resolves track"| node_shoukaku
node_play -->|"replies"| node_discord
node_compliment -->|"generates text"| node_openai
node_roast -->|"generates text"| node_openai
node_kiss -->|"generates text"| node_openai
node_compliment -->|"replies"| node_discord
node_roast -->|"replies"| node_discord
node_hug -->|"replies with GIF"| node_discord
node_kiss -->|"replies"| node_discord
node_ping -->|"replies"| node_discord
node_debug -->|"checks node status"| node_shoukaku
node_debug -->|"replies"| node_discord

click node_main "https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts"
click node_commands_loader "https://github.com/syihabudin081/tapir-bot/blob/main/src/handlers/commandHandler.ts"
click node_events "https://github.com/syihabudin081/tapir-bot/blob/main/src/handlers/eventHandler.ts"
click node_interactions "https://github.com/syihabudin081/tapir-bot/blob/main/src/events/interactionCreate.ts"
click node_logger "https://github.com/syihabudin081/tapir-bot/blob/main/src/utils/logger.ts"
click node_kazagumo "https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts"
click node_shoukaku "https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts"
click node_play "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/play.ts"
click node_queue "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/queue.ts"
click node_skip "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/skip.ts"
click node_stop "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/stop.ts"
click node_compliment "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/compliment.ts"
click node_roast "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/roast.ts"
click node_hug "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/hug.ts"
click node_kiss "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/kiss.ts"
click node_ping "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/ping.ts"
click node_debug "https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/debug.ts"

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_main,node_commands_loader,node_events,node_interactions,node_logger,node_user toneBlue
class node_kazagumo,node_shoukaku,node_play,node_queue,node_skip,node_stop toneAmber
class node_compliment,node_roast,node_hug,node_kiss,node_lavalink,node_openai toneMint
class node_ping,node_debug toneRose
class node_discord,node_giphy toneIndigo
```

## Components

### Bot runtime

- [Startup and clients](https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts): `src/index.ts`
- [Command loader](https://github.com/syihabudin081/tapir-bot/blob/main/src/handlers/commandHandler.ts): `src/handlers/commandHandler.ts`
- [Event and prefix routing](https://github.com/syihabudin081/tapir-bot/blob/main/src/handlers/eventHandler.ts): `src/handlers/eventHandler.ts`
- [Interaction routing](https://github.com/syihabudin081/tapir-bot/blob/main/src/events/interactionCreate.ts): `src/events/interactionCreate.ts`
- [Logging](https://github.com/syihabudin081/tapir-bot/blob/main/src/utils/logger.ts): `src/utils/logger.ts`

### Music playback

- [Player and queue client](https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts): `src/index.ts`
- [Lavalink client](https://github.com/syihabudin081/tapir-bot/blob/main/src/index.ts): `src/index.ts`
- [Play command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/play.ts): `src/commands/play.ts`
- [Queue command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/queue.ts): `src/commands/queue.ts`
- [Skip command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/skip.ts): `src/commands/skip.ts`
- [Stop command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/stop.ts): `src/commands/stop.ts`

### Social commands

- [Compliment command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/compliment.ts): `src/commands/compliment.ts`
- [Roast command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/roast.ts): `src/commands/roast.ts`
- [Hug command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/hug.ts): `src/commands/hug.ts`
- [Kiss command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/kiss.ts): `src/commands/kiss.ts`

### Utility commands

- [Ping command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/ping.ts): `src/commands/ping.ts`
- [Debug command](https://github.com/syihabudin081/tapir-bot/blob/main/src/commands/debug.ts): `src/commands/debug.ts`

### Other components

- **Discord user**
- **Discord**
- **Lavalink server**
- **OpenAI API**
- **GIF media**

## Connections

- Startup and clients → Command loader: loads commands
- Startup and clients → Event and prefix routing: loads events
- Startup and clients → Lavalink client: initializes
- Startup and clients → OpenAI API: initializes
- Startup and clients → Logging: logs through
- Lavalink client → Lavalink server: connects to
- Event and prefix routing → Discord: registers listeners
- Discord user → Discord: sends commands
- Discord → Event and prefix routing: delivers messages
- Event and prefix routing → Play command: dispatches
- Event and prefix routing → Queue command: dispatches
- Event and prefix routing → Skip command: dispatches
- Event and prefix routing → Stop command: dispatches
- Event and prefix routing → Compliment command: dispatches
- Event and prefix routing → Roast command: dispatches
- Event and prefix routing → Hug command: dispatches
- Event and prefix routing → Kiss command: dispatches
- Event and prefix routing → Ping command: dispatches
- Event and prefix routing → Debug command: dispatches
- Event and prefix routing → Interaction routing: registers
- Interaction routing → Discord: handles interactions
- Play command → Player and queue client: creates player
- Play command → Lavalink client: resolves track
- Play command → Discord: replies
- Compliment command → OpenAI API: generates text
- Roast command → OpenAI API: generates text
- Kiss command → OpenAI API: generates text
- Compliment command → Discord: replies
- Roast command → Discord: replies
- Hug command → Discord: replies with GIF
- Kiss command → Discord: replies
- Ping command → Discord: replies
- Debug command → Lavalink client: checks node status
- Debug command → Discord: replies
