Template repository for DiscordJS Projects
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 request or discovered a bug? Please open an Issue here on GitHub.
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!!!]
- Open up your favourite terminal (and navigate somewhere you want to download the repository to).
- 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. - 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. - Install all dependencies by typing
$npm install
- Copy config/config.template.js and paste it as
config/config.custom.js
OR usenpm run generate-config
. - Configure it in your favourite editor by editing
config/config.custom.js
. - Change some strings by running
$npm run setup-template
- Start it in development mode by running
$npm start
or start in production mode
$npm run start:prod
NOTE: You don't have to do that manually. Just run
npm run setup-template
!
- package.json
- pm2.ecosystem.json
- Bot Info Tagline
- Bot Info Author / Link
- Bot invite link in issues
- And you probably want to change this README here :P
- 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! 🎉
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 |
- NullDev/Arithmetica-Bot - A counting bot that supports arithmetic expressions
- NullDev/Discord-RoleShop - A Bot for a Roleshop with currency that can be earned by writing messages
- arellak/gpt_image_discord_bot - A Discord bot that generates images using DALL-E
- arellak/mukaji_chat - Chat bot using Markov chains
- altrusin/chimera - A Discord management bot
- ... you? Create an issue or a PR to get featured here!
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](https://img.shields.io/badge/Template%3A-NullDev%2FDiscordJS--Template-green?style=flat-square&logo=github)](https://github.com/NullDev/DiscordJS-Template)
Made with contrib.rocks.