A modern, extensible Discord bot template built with TypeScript, featuring a robust command system, event handling, and database integration using Drizzle ORM.
- TypeScript: Full type safety and modern JavaScript features
- Discord.js v14+: Latest Discord API support with components and interactions
- Drizzle ORM: Type-safe database operations with PostgreSQL
- Command Systems:
- Slash commands with autocomplete
- Message commands with aliases and permissions
- Dynamic help command with paginated UI
- Interactive Components: Buttons, modals, and select menus
- Event System: Client and guild event handling
- Utilities: Paginator for text displays, structured logging
- Hot Reload: Development with Bun for fast iteration
- Extensible Architecture: Modular loader system for easy expansion
- Node.js (v18+) or Bun
- PostgreSQL database
- Git
-
Click "Use this template" to create your own repository
-
Clone your new repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name -
Install dependencies:
bun install # or npm install
Run the automated setup script to configure your environment:
bun run initThis will:
- Install packages
- Prompt for your Discord bot token and database URL
- Create the database if it doesn't exist
- Set up the schema
Alternatively, set up manually:
-
Copy
example.envto.envand fill in your values:BOT_TOKEN=your_discord_bot_token DATABASE_URL=postgresql://user:password@localhost:5432/your_database -
Copy
src/example.config.tstosrc/config.tsand customize as needed -
Create the database and push the schema:
bun run create-db bunx drizzle-kit push
Start the bot in development mode with hot reload:
bun run devBuild and start the bot:
bun run start| Script | Description |
|---|---|
start |
Start the bot in production mode |
dev |
Start the bot in development mode with hot reload |
init |
Run the full setup process |
create-db |
Create the database if it doesn't exist |
db:push |
Push the schema to the database |
src/
├── classes/ # Core classes (Database, Logger, etc.)
├── commands/ # Command handlers
│ ├── message/ # Message commands
│ └── slash/ # Slash commands
├── events/ # Event handlers
├── helpers/ # Utility functions
├── interactions/ # Interactive components
├── structures/ # Base classes and types
├── triggers/ # Message triggers
├── types/ # TypeScript type definitions
├── utils/ # Utility classes
├── client.ts # Discord client setup
├── config.ts # Configuration (copy from example)
├── db/ # Database schema and setup
└── startup.ts # Application entry point
;help- Display all commands with pagination;ping- Check bot latency;invite- Get bot invite link;clear <amount>- Clear messages (requires permissions);eval <code>- Execute JavaScript (developer only)
/ping- Check bot latency/invite- Get bot invite link/eval- Execute JavaScript (developer only)
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This template is designed for learning, prototyping, and small-scale projects. It may not be suitable for large production bots without additional optimizations and security measures.