Caution
This repository is the one I personally use as a template for my projects. Please exercise caution and review the code before using it, as it is modified whenever I need to improve or implement something and may not correspond to the latest release. For better stability, always use the latest release.
This repository contains a basic template for creating Discord bots using discord.js
, pm2
for process management and .env
for environment variable configuration.
- Basic structure to start your own project.
- Discord.js: Library to interact with the Discord API.
- PM2: Process manager for Node.js applications, making it easy to run and monitor your bot.
- .env: Environment variable file to securely manage configuration settings.
- Custom Discord notification ErrorHandler: Sometimes you may encounter errors after deploying your bot; that's why I usually link
error handlers
to a channel in a private Discord server so I can get notified. - locales folder. Theres nothing like supporting multiple languages if you want your bot to be popular, more information about how to use this below.
- And much more!
- Base template
- Slash commands handlers
- Event handlers
- Interaction handlers
- Command options (cooldowns, devonly, database, ...)
- Installation guide
- MongoDB setup + examples
-
locale
to support multiple languages - Sharding support for scalability purposes
- Support server with test bot
-
README.md
files on each dir to explain it -
Error handling
notification on discord server -
utils
folder filled with utility examples likeembed pagination
,date formatter
,validators
,etc...
-
Prerequisites and dependencies
node.js
- version 18 or newer required 🚨discord.js
- version 14.18.0 or newer required 🚨mongoose
- version 8.12.1 or newer required 🚨 (can be disabled)dotenv
- not required but recommendedpm2
- not required but recommendednpm install pm2 -g
to install it globally
nodemon
- not required but recommendednpm install -g nodemon
to install it globally
-
Why this template? 🤔
This template contains a versatile design so you can create your own bot regardless of the idea behind it. This repository will be updated with every discord.js update, so you won't have to worry about deprecated code. -
Guides
- 💿 Installation
INSTALLATION.md
- 📃 locale (Multiple languages)
./locales/README.md
- Discord.js Guide
- 💿 Installation
- Ensure that any new functionality or feature is general-purpose and enhances the template's versatility. Avoid adding features that are too specialized or tailored to specific use cases.
- Add comments to help understand the code.
- Use default prettier settings. (ignore
.md
files) - Write clear and descriptive commit messages. Each commit should explain the purpose of the change succinctly.
- Update and maintain documentation for any new features or changes. Contributions should include clear explanations of functionality, configuration, and usage examples.
- Provide tests for new features when applicable. Contributions should not break existing functionality.
Note
Im a trainee developer, Any help or TIPs are welcome. Keep in mind that this is just a template for general-purpose bots; it has to be versatile , efficient, and lightweight. With that said , feel free to fork this repository and submit pull requests. Contributions are welcome!
- Mongoose docs MongoDB
- PM2 docs
- PermissionFlags
- SlashCommands
- EmbedBuilder
- ButtonBuilder
- ModalBuilder
- SelectMenus
- Cooldowns
- Sharding
- OAuth2
This project is licensed under the MIT License.