Skip to content

Commit a56d131

Browse files
committed
docs: update
1 parent 1d1cf5f commit a56d131

4 files changed

Lines changed: 88 additions & 61 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLAUDE.md

CLAUDE.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ bun run lint # Run oxlint
2121
bun run lint:fix # Auto-fix linting issues (oxlint)
2222
bun run test # Run all tests (vitest)
2323
bun run test:watch # Run tests in watch mode (vitest)
24-
bun run verify # Run format check, lint, type checking, and tests
24+
bun run verify # Format, lint-fix, type check, and test locally
25+
bun run ci # CI-safe checks without writing files
2526

2627
# Deployment
2728
bun run deploy-commands # Deploy slash commands to Discord (required after adding/modifying slash commands)
2829
bun run start # Production mode
29-
30-
# Database management
31-
bun run db:studio # Open Drizzle Studio GUI
3230
```
3331

3432
## Architecture & Key Patterns
@@ -40,7 +38,7 @@ The bot supports both legacy prefix commands and modern slash commands during th
4038
1. **Legacy Commands** (`src/commands/*.command.ts`)
4139
- Use the `Command` interface
4240
- Accessed via prefix (default: `!`)
43-
- Show migration notices encouraging slash command use
41+
- May show migration notices when linked to slash command replacements
4442
- Example: `!gan 14402`
4543

4644
2. **Slash Commands** (`src/slash-commands/*.command.ts`)
@@ -51,15 +49,16 @@ The bot supports both legacy prefix commands and modern slash commands during th
5149

5250
### Migration System
5351

54-
When users use legacy commands that have slash equivalents:
52+
When users use legacy commands that are linked to slash equivalents via `legacyName`:
5553

5654
- A temporary migration notice appears (15 seconds)
5755
- The legacy command still executes
58-
- Configured via `legacyName` property in slash commands
56+
- `!poll` currently keeps running without a migration notice
57+
- The mapping is configured via the `legacyName` property in slash commands
5958

6059
### Database Architecture
6160

62-
- **Drizzle ORM** with SQLite (`bun:sqlite`)
61+
- **Drizzle ORM** with SQLite through the libSQL client
6362
- Schema defined in `src/database/schema.ts`
6463
- Services pattern for database operations (`src/services/*.service.ts`)
6564
- Tables: `teams`, `team_members`, `polls`, `poll_votes`, `uwc_polls`, `uwc_poll_results`
@@ -77,23 +76,32 @@ When users use legacy commands that have slash equivalents:
7776
- **UwcPollService**: Tracks UWC polls, stores results, enables searching by achievement/game
7877
- **UwcHistoryService**: Retrieves and formats previous UWC poll history for auto-detection
7978
- **AutoPublishService**: Automatically publishes messages in configured announcement channels
79+
- **GameInfoService**, **TemplateService**, and **YouTubeService**: Power GAN command data fetching and formatting
80+
- **AchievementUnlocksService** and **ConnectApiService**: Support events and memory parsing features
81+
- **GithubReleaseService**: Fetches release information for `/status`
8082

8183
### Environment Variables
8284

83-
Required in `.env`:
85+
Required at startup:
8486

8587
- `DISCORD_TOKEN`: Bot token (required)
8688
- `DISCORD_APPLICATION_ID`: Bot application ID (required)
8789
- `RA_WEB_API_KEY`: RetroAchievements Web API key (required)
90+
91+
Feature-specific and optional configuration:
92+
8893
- `LEGACY_COMMAND_PREFIX`: Prefix for legacy commands (default: `!`)
89-
- `RA_CONNECT_API_KEY`: RetroAchievements Connect API key (future use)
94+
- `RA_CONNECT_API_KEY`: RetroAchievements Connect API key required for `!mem` achievement ID/URL lookups and code notes
95+
- `RA_CONNECT_API_USER`: RetroAchievements Connect API username (default: `RABot`)
9096
- `YOUTUBE_API_KEY`: For longplay searches in gan commands (optional, but recommended)
91-
- `MAIN_GUILD_ID`: Discord guild ID for the main RetroAchievements server (optional, but recommended)
92-
- `WORKSHOP_GUILD_ID`: Discord guild ID for the RetroAchievements Workshop server (optional, but recommended)
97+
- `MAIN_GUILD_ID`: Discord guild ID for the main RetroAchievements server (optional, but recommended for production guild authorization)
98+
- `WORKSHOP_GUILD_ID`: Discord guild ID for the RetroAchievements Workshop server (required for Workshop-only features)
9399
- `CHEAT_INVESTIGATION_CATEGORY_ID`: Category ID for RACheats team restrictions
100+
- `GAMBLER_ROLE_ID`: Discord role ID managed by `/events gambler` (required for Gambler role commands)
94101
- `UWC_VOTING_TAG_ID`: Forum tag ID for active UWC polls (optional)
95102
- `UWC_VOTE_CONCLUDED_TAG_ID`: Forum tag ID for completed UWC polls (optional)
96103
- `UWC_FORUM_CHANNEL_ID`: Forum channel ID for UWC auto-detection feature (optional)
104+
- `DEV_CHANNELS`: Comma-separated channel IDs where `!mem` may show code notes (optional)
97105
- `AUTO_PUBLISH_CHANNEL_IDS`: Comma-separated list of announcement channel IDs to auto-publish from (optional)
98106
- `NODE_ENV`: Set to "production" in production (default: "development")
99107
- `LOG_LEVEL`: Logging level - trace, debug, info, warn, error, fatal (default: "debug" in dev, "info" in prod)
@@ -114,7 +122,7 @@ The bot automatically provides context when new UWC (Unwelcome Concept) reports
114122
- Detects threads matching pattern: `12345: Achievement Title (Game Name)`
115123
- Queries database for previous UWC polls for the same achievement ID
116124
- Posts an automated message with links to up to 5 previous discussions
117-
- Shows poll dates, outcomes (Approved/Denied/Active/No Action), and vote results
125+
- Shows poll dates, active status when relevant, and the top vote result when available
118126
- Uses efficient database queries instead of Discord API calls for performance
119127

120128
### Auto-Publishing Feature
@@ -175,7 +183,7 @@ async execute(interaction, _client) {
175183

176184
## Logging System
177185

178-
The bot uses Pino for structured logging with the following features:
186+
The bot uses a small custom structured JSON logger with the following features:
179187

180188
### Log Levels
181189

@@ -223,10 +231,10 @@ The bot uses Pino for structured logging with the following features:
223231
- Runs under a process supervisor on the production server
224232
- No manual PM2 configuration needed
225233

226-
### Database Performance
234+
### Database
227235

228-
- SQLite WAL mode is enabled by default for better concurrent access
229-
- WAL mode allows concurrent reads during writes, ideal for Discord bot usage patterns
236+
- The database is a local SQLite file (`rabot.db`) accessed through Drizzle's libSQL adapter
237+
- Migrations live in `drizzle/` and are applied by `bun run db:migrate`
230238

231239
### Shutdown Handling
232240

@@ -241,7 +249,7 @@ Tests use [Vitest](https://vitest.dev/) as the test runner (configured in `vites
241249
## Common Gotchas
242250

243251
- Always use Bun commands (`bun run`, `bun install`) not npm/yarn/pnpm
244-
- Deploy slash commands after changes (`bun deploy-commands`)
252+
- Deploy slash commands after changes (`bun run deploy-commands`)
245253
- Check channel type before accessing properties like `topic` or `parentId`
246254
- Use proper null checks for Discord.js properties
247255
- Remember to handle both team IDs and names in TeamService methods

CONTRIBUTING.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ Thank you for your interest in contributing to RABot! This document provides gui
66

77
### Prerequisites
88

9-
- [Bun](https://bun.sh) 1.2.18 or higher
9+
- [Bun](https://bun.sh) 1.3.10 or higher
1010
- A Discord application for testing (create one at [Discord Developer Portal](https://discord.com/developers/applications))
11+
- A RetroAchievements Web API key for local bot startup
1112
- Basic knowledge of TypeScript and Discord.js
1213

1314
### Setting Up Your Development Environment
1415

1516
1. **Fork and clone the repository**
1617

1718
```bash
18-
git clone https://github.com/YOUR-USERNAME/RABot.git
19-
cd RABot
19+
git clone https://github.com/YOUR-USERNAME/RABot-Next.git
20+
cd RABot-Next
2021
```
2122

2223
2. **Install dependencies**
@@ -36,20 +37,20 @@ Thank you for your interest in contributing to RABot! This document provides gui
3637
4. **Initialize the database**
3738

3839
```bash
39-
bun db:generate
40-
bun db:migrate
41-
bun db:seed # Optional: adds default teams
40+
bun run db:generate
41+
bun run db:migrate
42+
bun run db:seed # Optional: adds default teams
4243
```
4344

44-
5. **Deploy slash commands to your test server**
45+
5. **Deploy global slash commands**
4546

4647
```bash
47-
bun deploy-commands
48+
bun run deploy-commands
4849
```
4950

5051
6. **Run the bot in development mode**
5152
```bash
52-
bun dev
53+
bun run dev
5354
```
5455

5556
## Development Workflow
@@ -76,21 +77,24 @@ git checkout -b fix/issue-description
7677
Before committing, ensure your code passes all checks:
7778

7879
```bash
79-
bun run verify # Runs lint, type checking, and tests
80+
bun run verify # Formats, lint-fixes, type checks, and tests
8081
```
8182

83+
Use `bun run ci` when you want the non-mutating CI check sequence.
84+
8285
Individual checks:
8386

8487
```bash
85-
bun lint # Check code style
86-
bun lint:fix # Auto-fix style issues
87-
bun tsc # TypeScript type checking (via tsgo)
88-
bun run test # Run tests (via vitest)
88+
bun run format:check # Check formatting without writing
89+
bun run lint # Check code style
90+
bun run lint:fix # Auto-fix lint issues
91+
bun run tsc # TypeScript type checking (via tsgo)
92+
bun run test # Run tests (via vitest)
8993
```
9094

9195
### 4. Commit Your Changes
9296

93-
- Use **conventional commits** format:
97+
- Use **commitizen-style conventional commits** format:
9498
- `feat:` for new features
9599
- `fix:` for bug fixes
96100
- `docs:` for documentation changes
@@ -110,7 +114,7 @@ git commit -m "docs: update setup instructions for Bun 1.3"
110114

111115
1. Push your branch to your fork
112116
2. Open a pull request against the `main` branch
113-
3. Fill out the pull request template with:
117+
3. Include in the pull request description:
114118
- Clear description of changes
115119
- Testing instructions
116120
- Any breaking changes
@@ -130,6 +134,7 @@ git commit -m "docs: update setup instructions for Bun 1.3"
130134
- **Commands** go in `src/commands/` (legacy) or `src/slash-commands/` (preferred).
131135
- **Business logic** belongs in `src/services/`.
132136
- **Shared utilities** go in `src/utils/`.
137+
- **Shared test helpers** go in `src/test/`.
133138
- **Database operations** use the service layer pattern.
134139

135140
### Command Development
@@ -145,6 +150,7 @@ When creating new commands:
145150
Example slash command structure:
146151

147152
```typescript
153+
import { SlashCommandBuilder } from "discord.js";
148154
import type { SlashCommand } from "../models";
149155

150156
export default {

README.md

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ RABot utilizes:
2828

2929
## Requirements
3030

31-
- [Bun](https://bun.sh) 1.3.6+
32-
- A Discord bot token
31+
- [Bun](https://bun.sh) 1.3.10+
32+
- A Discord application ID, bot token, and RetroAchievements Web API key
3333

3434
## Installation
3535

@@ -55,12 +55,17 @@ Then edit `.env` with your configuration:
5555
- `DISCORD_APPLICATION_ID` - Your bot's application ID from Discord Developer Portal
5656
- `LEGACY_COMMAND_PREFIX` - Command prefix for legacy commands (default: `!`)
5757
- `RA_WEB_API_KEY` - Your RetroAchievements Web API key
58+
- `RA_CONNECT_API_KEY` - RetroAchievements Connect API key required for `!mem` achievement ID/URL lookups and code notes
59+
- `RA_CONNECT_API_USER` - RetroAchievements Connect API username (default: `RABot`)
5860
- `YOUTUBE_API_KEY` - Your YouTube Data API v3 key (optional, for `/gan` longplay searches)
59-
- `MAIN_GUILD_ID` - Discord guild ID for the main RetroAchievements server
60-
- `WORKSHOP_GUILD_ID` - Discord guild ID for the RetroAchievements Workshop server
61+
- `MAIN_GUILD_ID` - Discord guild ID for the main RetroAchievements server (optional, but recommended for production guild authorization)
62+
- `WORKSHOP_GUILD_ID` - Discord guild ID for the RetroAchievements Workshop server (required for Workshop-only features)
63+
- `GAMBLER_ROLE_ID` - Discord role ID managed by `/events gambler` (required for Gambler role commands)
64+
- `CHEAT_INVESTIGATION_CATEGORY_ID` - Category ID required for RACheats `/pingteam ping` restrictions
6165
- `UWC_VOTING_TAG_ID` - Forum tag ID for active UWC polls (optional)
6266
- `UWC_VOTE_CONCLUDED_TAG_ID` - Forum tag ID for completed UWC polls (optional)
6367
- `UWC_FORUM_CHANNEL_ID` - Forum channel ID for UWC auto-detection (optional)
68+
- `DEV_CHANNELS` - Comma-separated channel IDs where `!mem` may show code notes (optional)
6469
- `AUTO_PUBLISH_CHANNEL_IDS` - Comma-separated list of announcement channel IDs to auto-publish from (optional)
6570
- `NODE_ENV` - Environment mode: `development` or `production` (default: `development`)
6671
- `LOG_LEVEL` - Logging level: `trace`, `debug`, `info`, `warn`, `error`, `fatal` (default: `debug` in dev, `info` in prod)
@@ -70,17 +75,17 @@ Then edit `.env` with your configuration:
7075
Initialize the database:
7176

7277
```bash
73-
bun db:generate # Generate migration files
74-
bun db:migrate # Apply migrations
75-
bun db:seed # Seed default teams (optional)
78+
bun run db:generate # Generate migration files
79+
bun run db:migrate # Apply migrations
80+
bun run db:seed # Seed default teams (optional)
7681
```
7782

7883
## Deploying Slash Commands
7984

80-
After adding your bot to a server, deploy the slash commands:
85+
Deploy the application's global slash commands:
8186

8287
```bash
83-
bun deploy-commands
88+
bun run deploy-commands
8489
```
8590

8691
This needs to be run:
@@ -94,38 +99,40 @@ This needs to be run:
9499
### Development
95100

96101
```bash
97-
bun dev # Runs with auto-restart on file changes
102+
bun run dev # Runs with auto-restart on file changes
98103
```
99104

100105
### Production
101106

102107
```bash
103-
bun start # Standard run
108+
bun run start # Standard run
104109
```
105110

106111
For production deployments, the bot is automatically deployed via Forge when changes are merged to the main branch. The bot runs under a process supervisor on the production server.
107112

108113
## Available Scripts
109114

110-
- `bun dev` - Run in development mode with hot reload
111-
- `bun start` - Run in production mode
112-
- `bun deploy-commands` - Deploy slash commands to Discord
113-
- `bun db:generate` - Generate database migrations
114-
- `bun db:migrate` - Apply database migrations
115+
- `bun run dev` - Run in development mode with hot reload
116+
- `bun run start` - Run in production mode
117+
- `bun run deploy-commands` - Deploy slash commands to Discord
118+
- `bun run db:generate` - Generate database migrations
119+
- `bun run db:migrate` - Apply database migrations
120+
- `bun run db:seed` - Seed default teams
115121
- `bun run format` - Format code with oxfmt
116122
- `bun run format:check` - Check formatting without writing
117-
- `bun lint` - Run oxlint
118-
- `bun lint:fix` - Run oxlint with auto-fix
119-
- `bun tsc` - Run TypeScript type checking (via tsgo)
123+
- `bun run lint` - Run oxlint
124+
- `bun run lint:fix` - Run oxlint with auto-fix
125+
- `bun run tsc` - Run TypeScript type checking (via tsgo)
120126
- `bun run test` - Run all tests
121127
- `bun run test:watch` - Run tests in watch mode
122-
- `bun verify` - Run format check, lint, type checking, and tests
128+
- `bun run verify` - Format, lint-fix, type check, and test locally
129+
- `bun run ci` - Run CI-safe format check, lint, type checking, and tests
123130

124131
## Commands
125132

126133
### 🆕 Migration Notice
127134

128-
RABot is transitioning to slash commands! When you use a legacy prefix command (e.g., `!gan`), you'll see a migration notice encouraging you to use the modern slash command version (e.g., `/gan`). The legacy command will still work during the transition period.
135+
RABot is transitioning to slash commands. When you use a linked legacy prefix command (for example, `!gan`), you'll see a migration notice encouraging you to use the modern slash command version (for example, `/gan`). The legacy command will still work during the transition period.
129136

130137
### Slash Commands (Recommended)
131138

@@ -138,20 +145,24 @@ RABot is transitioning to slash commands! When you use a legacy prefix command (
138145
- `/gan2 <game-id>` - Generate pretty achievement news template with colors
139146
- `/pingteam` - Team management system (Workshop server only)
140147
- `/pingteam ping <team>` - Ping all members of a team
141-
- `/pingteam add <team> <user>` - Add user to team (admin only)
142-
- `/pingteam remove <team> <user>` - Remove user from team (admin only)
143-
- `/pingteam create <name>` - Create a new team (admin only)
144-
- `/uwc` - Create an Unwelcome Concept poll (Workshop server only, auto-manages forum tags)
148+
- `/pingteam add <team> <user>` - Add user to team
149+
- `/pingteam remove <team> <user>` - Remove user from team
150+
- `/pingteam create <name>` - Create a new team
151+
- `/uwc` - Create an Unwelcome Concept poll (Workshop server only, requires UWC role or admin, auto-manages forum tags)
145152
- **Auto-detection**: When a new UWC thread is created in the configured forum channel with format `12345: Achievement Title (Game Name)`, the bot automatically posts links to previous discussions for that achievement
153+
- `/events gambler` - Manage the Gambler role (server only)
154+
- `/events gambler reset` - Remove the Gambler role from all users
155+
- `/events gambler award <user>` - Manually award the Gambler role
156+
- `/events gambler award-all <ach1> <ach2> <ach3> [ach4]` - Award the role to users who unlocked at least 3 listed achievements
146157
- `/dadjoke` - Get a random dad joke
147158
- `/frames <input>` - Convert between time and frames at different frame rates
148159

149-
### Legacy Prefix Commands (Being Migrated)
160+
### Legacy Prefix Commands
150161

151162
The bot still supports the following legacy prefix commands (all prefixed with `!` by default):
152163

153164
- `!topic` - Display the current channel topic
154-
- `!rule [number]` - Display server rules
165+
- `!rules [number|coc]` - Display server rules (`!rule`, `!rule2`, and `!rulecoc` aliases are also supported)
155166
- `!contact` - Show contact information for various RA teams
156167
- `!poll` - Create a simple poll
157168
- `!tpoll` - Create a timed poll
@@ -171,6 +182,7 @@ src/
171182
├── handlers/ # Message and event handlers
172183
├── models/ # TypeScript interfaces and types
173184
├── services/ # Business logic services
185+
├── test/ # Shared test database and mocks
174186
└── utils/ # Utility functions and logging
175187
```
176188

0 commit comments

Comments
 (0)