A monorepo TypeScript template for building multiple Discord bots and utilities with shared logic, types, and tools. This project uses Turborepo for workspace management and a clean modular structure.
bot-template/
│
├─ package.json # Root config (workspaces, scripts, dependencies)
├─ tsconfig.json # Shared TypeScript config
├─ .gitignore
│
├─ packages/ # Reusable shared packages
│ ├─ core/ # Core modules (logger, DB, config loader, handlers)
│ │ └─ src/
│ │ ├─ index.ts # Exports every core feature.
│ │ ├─ baseClient.ts
│ │ ├─ logger.ts
│ │ ├─ database.ts
│ │ ├─ config.ts
│ │ └─ handlers/
│ │ ├─ errors.ts
│ │ ├─ loadCommands.ts
│ │ └─ loadEvents.ts
│ │
│ └─ shared/ # Shared types, constants, helpers
│ └─ src/
│ ├─ index.ts
│ └─ types.ts
│
├─ bots/ # All Discord bots
│ ├─ client/ # Main client bot
│ │ └─ src/
│ │ ├─ index.ts # Entrypoint
│ │ ├─ commands/ # Slash & prefix commands
│ │ └─ events/ # Event handlers
│ │
│ └─ helper/ # Secondary helper bot
│ └─ src/
│ ├─ index.ts
│ ├─ events/
│ └─ commands/
│
└─ tools/ # Utility scripts / dev tools
└─ generate-docs/
└─ src/index.ts
- Multi-bot support
bots/client
= main Discord botbots/helper
= secondary helper bot
- Shared logic via packages
packages/core
→ client, logging, database, config, etc.packages/shared
→ types, constants, utilities
- Turborepo for fast builds & caching
- TypeScript out of the box
- Clean structure for commands, events, and tools
- Easily extendable with more bots or services
git clone https://github.com/ProjectDiscord/bot-template.git
cd bot-template
npm install
# Database
DATABASE_URL="mysql://<username>:<password>@<host>:<port>/<database>"
# Main Client Bot
CLIENT_TOKEN="your-client-bot-token"
CLIENT_ID="your-client-id"
CLIENT_SECRET="your-client-secret"
CLIENT_PREFIX="?"
# Helper Bot (optional)
HELPER_CLIENT_TOKEN="your-helper-bot-token"
HELPER_CLIENT_ID="your-helper-client-id"
HELPER_CLIENT_SECRET="your-helper-client-secret"
HELPER_CLIENT_PREFIX="?"
# Error handling
ENABLE_ERROR_HANDLER=true
ENABLE_SEND_TO_WEBHOOK=true
ERROR_WEBHOOK_URL="your-discord-webhook-url"
# Start main client bot
npm run start:bot
# Start helper bot
npm run start:helper
From root:
npm run start:bot # Run main client bot
npm run start:helper # Run helper bot
npm run build # Build all packages & bots
npm run lint # Run linter
npm run format # Run Formatter
- packages/core → common modules like client, logger, database, config loader
- packages/shared → shared types/interfaces/constants
- bots/client → main Discord bot with commands & events
- bots/helper → additional bot/service
- Fork the repo
- Create a feature branch (
git checkout -b feature/my-feature
) - Commit changes (
git commit -m 'Add my feature'
) - Push branch (
git push origin feature/my-feature
) - Create a Pull Request
MIT License © ProjectDiscord