Skip to content

LynnuxDev/Akira-Rewrite

Discord.js Bot Template (TypeScript)

Maintainability Discord.js License: BSD-4-Clause

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.

Features

  • Written in TypeScript for type safety.
  • Supports pnpm, npm, and yarn for installation.
  • Uses Prisma 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

.
├── prisma               # Prisma schema and database file
├── scripts              # Package scripts (DB setup, linting, etc.)
├── src                  # Source code
│   ├── bot              # Core bot logic
│   ├── commands         # Command 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

Installation

  1. Clone the repository:

    git clone https://github.com/Dark-LYNN/DiscordBotTemplate.git
    cd discordbot-template
  2. Install dependencies with your preferred package manager:

    # Using pnpm
    pnpm install
    
    # Using npm
    npm install
    
    # Using yarn
    yarn install
  3. Set up the environment variables:

    • Create a .env file in the root directory.

    • Add your bot token and database URL:

      DATABASE_URL=file:'./database.db'
      
      DISCORD_TOKEN=your-bot-token
      DISCORD_CLIENT_ID=your-bot-client-id
  4. Initialize the database:

    npm run db  # or pnpm db / yarn db

Usage

Development Mode

npm run dev  # or pnpm dev / yarn dev

This will start the bot using nodemon with ts-node to watch for file changes.

Production Mode

npm run build  # or pnpm build / yarn build
npm run start  # or pnpm start / yarn start

This will compile TypeScript to JavaScript and start the bot.

Scripts

  • lint – Run ESLint
  • lint:fix – Auto-fix linting issues
  • lint:spell – Run spell checking
  • lint:format – Format code with Prettier
  • release – Release a new version
  • test:all – Run all tests
  • db – Setup the database

Contributing

Contributions are welcome! Feel free to open an issue or pull request.

For info about contributing see our CONTRIBUTING.md.

License

This project is licensed under the BSD-4-Clause License. See the LICENSE file for details.

Acknowledgments

Thanks to all contributors and open-source projects that inspired this template.

Sponsor this project

Contributors 2

  •  
  •