Contributing Guide
Contributing Guide
Section titled “Contributing Guide”How to add features, write commands, and maintain code quality for the Project 1999 Discord bot.
Adding a New Command
Section titled “Adding a New Command”- Create the file in the appropriate
commands/<category>/folder. - Export
data— aSlashCommandBuilderdefining the command name, description, and options. - Export
execute— an async function that handles the command interaction. - (Optional) Export
autocompleteif your command uses autocomplete options. - (Optional) Export
handleModalif your command uses modal submissions. - (Optional) Export
permissions(string or string[]) to restrict the command to users with that Discord permission. - Register the command by running
npx esrun register_guild_commands.ts.
Command Template
Section titled “Command Template”/** * `/mycommand` command -- brief description of what it does. * * @module */import { ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
export const data = new SlashCommandBuilder() .setName('mycommand') .setDescription('Does something useful');
export async function execute(interaction: ChatInputCommandInteraction) { await interaction.reply('Hello!');}Using the Shared Helpers
Section titled “Using the Shared Helpers”For census-related commands, use the helpers in census_functions.ts:
userMustExist()/userMustNotExist()— DKP record validationtoonMustExist()/toonMustNotExist()— character name validationclassMustExist()/levelMustBeValid()— input validationdeclareData()— shared slash command builder factory for/main,/alt,/botsuggestActiveToons()— autocomplete helperdeclare()— creates a Census recordinsertUser()— onboards a new member into DKP
Adding a New Entity
Section titled “Adding a New Entity”- Create a new file in
entities/with a TypeORM@Entitydecorator. - Add TSDoc: class-level description of the table and field-level docs for non-obvious columns.
- The entity will be auto-discovered via the
./entities/*.jsglob inapp_data.ts. - Create the table in PostgreSQL manually (synchronise is disabled).
Code Style
Section titled “Code Style”- TypeScript with strict mode enabled
- ESM modules (
"type": "module"in package.json) - Prettier + ESLint for formatting — run your editor’s format-on-save
- Use
lodashfor utility functions (already a dependency) - Capitalise character names with
_.capitalize()before storing
TSDoc Conventions
Section titled “TSDoc Conventions”Every file should have a module-level TSDoc block before the first import:
/** * Brief description of what this module does. * * Longer explanation if needed, including relationships to other modules * and any important behavioural notes. * * @module */For exported functions, add parameter and return descriptions:
/** * Brief description. * @param name - What this parameter is. * @returns What the function returns. * @throws When it throws. */Use backtick-code (e.g. `ClassName`) to reference types from other modules. Use {@link} only for same-file references.
PR Workflow
Section titled “PR Workflow”- Create a branch from
main. - Make your changes with appropriate TSDoc.
- Run
npm run buildto verify TypeScript compilation. - Run
npm run docs:buildto verify documentation generation. - Submit a pull request against
main. - The docs workflow will automatically build and deploy on merge.