Skip to content
/ DiscordJS-Template Public template

Template repository for DiscordJS Projects: sharding, i18n, QuickDB, PM2, Auto deploy

License

Notifications You must be signed in to change notification settings

NullDev/DiscordJS-Template

Repository files navigation

DiscordJS-Template

NullDev/DiscordJS-Template GitHub closed issues

Template repository for DiscordJS Projects


❓ What is this?

This is a template repository for DiscordJS projects. It includes a basic setup for a Discord bot with:

  • A command handler
  • An event handler
  • A typed (autocomplete) config system that supports nesting and functions
  • A logger (both console and file)
  • Slash command support
  • Multi language support (i18n) in both messages and commands
  • QuickDB for persistent storage
  • Deployment via GitHub Actions and PM2
  • ESLint
  • Cron jobs for scheduled tasks such as cleanups (logs / database)
  • Sharding support
  • Admin / User only commands
  • Easy to set up
  • Minimalistic REST-API base for potential dashboard or OAuth

💠 Feature requests & Issues

Feature request or discovered a bug? Please open an Issue here on GitHub.


💮 Other branches

There are other branches with different feature sets:

  • master - The default branch with all features (if you can read this, you are already here)
  • no-i18n - No i18n / multi language support, command localization, etc
  • webserver - A basic webserver with a REST-API base e.g. for OAuth or a dashboard [CURRENTLY OUTDATED!!!]

🔧 Dev Setup

  1. Open up your favourite terminal (and navigate somewhere you want to download the repository to).

  2. Make sure you have NodeJS installed (>= v20.0.0). Test by entering
    $ node -v
    If this returns a version number, NodeJS is installed. If not, get NodeJS here.

  3. Clone the repository and navigate to it. If you have Git installed, type
    $ git clone https://github.com/NullDev/DiscordJS-Template.git && cd DiscordJS-Template
    If not, download it here and extract the ZIP file.
    Then navigate to the folder.

  4. Install all dependencies by typing
    $ npm install

  5. Copy config/config.template.js and paste it as config/config.custom.js OR use npm run generate-config.

  6. Configure it in your favourite editor by editing config/config.custom.js.

  7. Change some strings by running
    $ npm run setup-template

  8. Start it in development mode by running
    $ npm start
    or start in production mode
    $ npm run start:prod


📡 Things to change in the template

NOTE: You don't have to do that manually. Just run npm run setup-template !


🚀 Deployment

  • Clone the repo to your server
  • Add the correct secrets to your repository settings
    • SSH_HOST: The host (domain / IP) of the server you want to deploy to
    • SSH_PORT: The SSH port of the server you want to deploy to (usually 22)
    • SSH_USER: The SSH user of the server you want to deploy to
    • SSH_KEY: The private SSH key of the server you want to deploy to
    • REPO_PATH: The path to the repository on the server (where you cloned to, e.g.: /home/bots/MyCoolBot)
    • PM2_HOME: [OPTIONAL] The path to the PM2 home directory, if it's custom (e.g.: /home/bots/.pm2)
  • Install PM2 on the server by running npm install pm2 -g
  • Start the bot initially by running pm2 start pm2.ecosystem.json
  • Save the current PM2 configuration by running pm2 save
  • Enable PM2 to start on boot by running pm2 startup and following the instructions
  • Done! 🎉

🔩 Configuration

Once the config has been copied like described in Step 4 of the setup, it can be changed to your needs:

Config Key Description Data Type Default value
discord:
bot_token
Auth Token of the Discord bot. Can be created here. String N/A

⭐ Bots using this Template


📜 License

This Template is Licensed under MIT.
You are free to change the license in your Project to whatever you want!
But please credit this Repository here in some way, shape or form :)

Here's a bade you can use:

NullDev/DiscordJS-Template

[![NullDev/DiscordJS-Template](https://img.shields.io/badge/Template%3A-NullDev%2FDiscordJS--Template-green?style=flat-square&logo=github)](https://github.com/NullDev/DiscordJS-Template)

:octocat: Contributors

Made with contrib.rocks.


banner