This is a template for a Discord.js bot written in TypeScript.
It is designed to work with pnpm, npm, and yarn and
includes a Prisma database integration.
The template is licensed under BSD-4-Clause and
comes with essential GitHub-related files.
- Written in TypeScript for type safety.
- Supports pnpm, npm, and yarn for installation.
- Uses kysely as the database ORM.
- Pre-configured ESLint and Prettier for code quality.
- Includes GitHub-related files (e.g.,
.gitignore,LICENSE,Issue Templates). - Organized structure with handlers for commands, events, interactions, and loops.
- Custom logging with Winston.
Project Structure
.
├── database # default location for database files.
├── scripts # Package scripts (DB setup, linting, etcetera.)
├── src # Source code
│ ├── bot # Core bot logic
│ ├── commands # Command files
│ ├── database # Database related files.
│ ├── events # Event listeners
│ ├── middleware # Middleware for permission checks
│ ├── tests # Unit tests
│ ├── types # TypeScript types
│ └── utils # Utility functions
├── .eslintrc.cjs # ESLint configuration
├── .prettierrc # Prettier configuration
├── package.json # Project metadata and dependencies
├── tsconfig.json # TypeScript configuration
├── LICENSE # BSD-4-Clause License
└── README.md # Project documentation-
Clone the repository:
git clone https://github.com/Dark-LYNN/DiscordBotTemplate.git cd discordbot-template -
Install dependencies with your preferred package manager:
# Using pnpm pnpm install # Using npm npm install # Using yarn yarn install
-
Set up the environment variables:
-
Create a
.envfile in the root directory. -
Add your bot token and database URL:
DISCORD_TOKEN=your-bot-token DISCORD_CLIENT_ID=your-bot-client-id
-
-
Initialize the database:
npm run db:migrate # or pnpm db:migrate / yarn db:migrate
npm run dev # or pnpm dev / yarn devThis will start the bot using nodemon with
ts-node to watch for file changes.
npm run build # or pnpm build / yarn build
npm run start # or pnpm start / yarn startThis will compile TypeScript to JavaScript and start the bot.
lint– Run ESLintlint:fix– Auto-fix linting issueslint:spell– Run spell checkinglint:format– Format code with Prettierrelease– Release a new versiontest:all– Run all testsdb– Setup the database
Contributions are welcome! Feel free to open an issue or pull request.
For info about contributing see our CONTRIBUTING.md.
This project is licensed under the BSD-4-Clause License. See the LICENSE file for details.
Thanks to all contributors and open-source projects that inspired this template.