You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9d009c0
Browse filesBrowse the repository at this point in the historyBrowse files
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Project Overview
6
+
7
+
**ref-bot** is a Discord bot (Node.js + discord.js v14) that queries amateur radio reflector APIs (URF/MREF) and displays status information as formatted Discord embeds via slash commands.
8
+
9
+
## Commands
10
+
11
+
```bash
12
+
# Install dependencies
13
+
npm install
14
+
15
+
# Run locally
16
+
node index.js
17
+
18
+
# Register/update slash commands with Discord API (required after adding/changing commands)
19
+
node deploy-commands.js
20
+
21
+
# Lint
22
+
npx eslint .
23
+
24
+
# Docker
25
+
docker-compose up -d
26
+
```
27
+
28
+
There are no automated tests.
29
+
30
+
## Architecture
31
+
32
+
**Entry point**: `index.js` — loads all commands from `commands/` dynamically, handles Discord interactions, enforces a cooldown system (3s default, 10s for reflector commands).
33
+
34
+
**Command structure** (`commands/reflector/`): Each command exports a `data` property (SlashCommandBuilder) and an `execute(interaction)` function. Commands use `undici.request()` to call the configured reflector's REST API endpoints (`/json/status`, `/json/metadata`, `/json/stations`, `/json/peers`, `/json/links`) and reply with EmbedBuilder formatted messages. All replies are ephemeral.
35
+
36
+
**Data flow**: Discord slash command → `index.js` interaction handler → command lookup → HTTP request to reflector API → parse JSON → format Discord embed → ephemeral reply.
37
+
38
+
**Events** (`events/`): `ready.js` and `interactionCreate.js` exist but contain duplicate/minimal logic — the primary interaction handling lives in `index.js`.
39
+
40
+
## Configuration
41
+
42
+
Copy `config.json-example` to `config.json` (gitignored):
43
+
44
+
```json
45
+
{
46
+
"token": "", // Discord bot token
47
+
"clientId": "", // Discord application ID
48
+
"guildId": "", // Discord server/guild ID
49
+
"icon": "", // Embed icon URL
50
+
"url": ""// Reflector API base URL (e.g. https://reflector.example.com)
51
+
}
52
+
```
53
+
54
+
For Docker, `config.json` is stored at `/opt/ref-bot/config.json` on the host and symlinked into the container.
55
+
56
+
## Adding a New Command
57
+
58
+
1. Create a file in `commands/reflector/` exporting `data` (SlashCommandBuilder) and `execute`.
59
+
2. Run `node deploy-commands.js` to register it with Discord.
60
+
3. The command is auto-loaded by `index.js` on startup — no other wiring needed.
61
+
62
+
## Code Style
63
+
64
+
ESLint enforces: tabs for indentation, single quotes, stroustrup brace style, max 4 nested callbacks. Run `npx eslint .` before committing.
0 commit comments