Thank you for your interest in contributing to RABot! This document provides guidelines and instructions for contributing to the official RetroAchievements Discord bot.
- Bun 1.2.18 or higher
- A Discord application for testing (create one at Discord Developer Portal)
- Basic knowledge of TypeScript and Discord.js
-
Fork and clone the repository
git clone https://github.com/YOUR-USERNAME/RABot.git cd RABot -
Install dependencies
bun install
-
Set up environment variables
cp .env.example .env
Edit
.envwith your Discord bot token and other required configuration. -
Initialize the database
bun db:generate bun db:migrate bun db:seed # Optional: adds default teams -
Deploy slash commands to your test server
bun deploy-commands
-
Run the bot in development mode
bun dev
Always create a new branch for your changes:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-description- Follow the existing code style - The project uses oxlint and oxfmt for consistency.
- Write TypeScript - All code must be properly typed.
- Add tests - New functionality should include tests.
- Update documentation - Keep README and JSDoc comments up to date.
Before committing, ensure your code passes all checks:
bun run verify # Runs lint, type checking, and testsIndividual checks:
bun lint # Check code style
bun lint:fix # Auto-fix style issues
bun tsc # TypeScript type checking (via tsgo)
bun run test # Run tests (via vitest)- Use conventional commits format:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions/changesrefactor:for code refactoringchore:for maintenance tasks
Examples:
git commit -m "feat: add team export command"
git commit -m "fix: handle empty poll options correctly"
git commit -m "docs: update setup instructions for Bun 1.3"- Push your branch to your fork
- Open a pull request against the
mainbranch - Fill out the pull request template with:
- Clear description of changes
- Testing instructions
- Any breaking changes
- Related issues
- Use strict TypeScript settings (already configured).
- Define interfaces for all data structures.
- Avoid
anytype - useunknownif type is truly unknown. - Prefer
interfaceovertypefor object shapes.
- Commands go in
src/commands/(legacy) orsrc/slash-commands/(preferred). - Business logic belongs in
src/services/. - Shared utilities go in
src/utils/. - Database operations use the service layer pattern.
When creating new commands:
- Prefer slash commands over legacy prefix commands.
- Use the
SlashCommandinterface fromsrc/models/. - Include proper error handling and user feedback.
- Add cooldowns where appropriate.
- Consider guild restrictions if command is server-specific.
Example slash command structure:
import type { SlashCommand } from "../models";
export default {
data: new SlashCommandBuilder().setName("example").setDescription("Example command"),
cooldown: 5,
async execute(interaction, client) {
// Command logic here
},
} satisfies SlashCommand;- Write tests for services and utilities.
- Use
createTestDb()fromsrc/test/create-test-db.tsfor service tests that need a real database. - Use the existing mock utilities in
src/test/mocks/for Discord and API mocks. - Test both success and error cases.
- Keep tests focused and independent.
- Comments should explain "why", not "what".
- Add JSDoc comments for public functions and complex logic.
- Code passes
bun run verify. - Tests are included for new functionality.
- Documentation is updated if needed.
- No console.logs or debug code left in.
- Commit messages follow conventional format.
- What - Brief summary of changes.
- Why - Motivation and context.
- How - Technical approach if non-obvious.
- Testing - How to test the changes.
- Breaking Changes - Any compatibility issues.
- PRs require at least one approval.
- Address reviewer feedback promptly.
- Keep PRs focused - one feature/fix per PR.
- Be open to suggestions and constructive criticism.
Please follow our Code of Conduct in all interactions.
- Check existing issues and discussions first.
- Join our Discord server for community support.
- Use clear, descriptive titles for issues.
- Provide reproduction steps for bugs.
Contributors will be recognized in our release notes and documentation. Thank you for helping improve RABot!