https://github.com/miguelmikkey/discordjs-bot-template
This repository is a flexible, modular template for building Discord bots with Discord.js. Itβs designed to be easily adapted for a wide range of projects.
https://github.com/miguelmikkey/discordjs-bot-template
bot discord discord-bot discord-bot-template discord-js-bot discord-js-v14 discordjs javascript
Last synced: about 2 months ago
JSON representation
This repository is a flexible, modular template for building Discord bots with Discord.js. Itβs designed to be easily adapted for a wide range of projects.
- Host: GitHub
- URL: https://github.com/miguelmikkey/discordjs-bot-template
- Owner: miguelmikkey
- License: mit
- Created: 2025-02-14T14:21:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-21T06:07:10.000Z (about 1 year ago)
- Last Synced: 2026-04-18T07:39:33.371Z (2 months ago)
- Topics: bot, discord, discord-bot, discord-bot-template, discord-js-bot, discord-js-v14, discordjs, javascript
- Language: JavaScript
- Homepage:
- Size: 129 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Discord.js Bot template | 2025 β








> [!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**](https://github.com/miguelmikkey/discordjs-bot-template/releases/).
This repository contains a basic template for creating Discord bots using `discord.js`, `pm2` for process management and `.env` for environment variable configuration.
## Features π¨
- **Basic structure** to start your own project.
- [**Discord.js**](https://discord.js.org/): Library to interact with the Discord API.
- [**PM2**](https://pm2.keymetrics.io/): Process manager for Node.js applications, making it easy to run and monitor your bot.
- [**.env**](https://www.npmjs.com/package/dotenv): Environment variable file to securely manage configuration settings.
- [**Custom Discord notification ErrorHandler**](https://github.com/miguelmikkey/discordjs-bot-template/blob/main/INSTALLATION.md#7-test-the-bot-): 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**](https://github.com/miguelmikkey/discordjs-bot-template/tree/main/locales/README.md) 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!*
## To-Do List π
- [x] Base template
- [x] Slash commands handlers
- [x] Event handlers
- [x] Interaction handlers
- [x] Command options (cooldowns, devonly, database, ...)
- [x] [Installation](https://github.com/miguelmikkey/discordjs-bot-template/blob/main/INSTALLATION.md) guide
- [x] MongoDB setup + examples
- [x] `locale` to support multiple languages
- [ ] Sharding support for scalability purposes
- [ ] Support server with test bot
- [x] `README.md` files on each dir to explain it
- [x] `Error handling` notification on discord server
- [ ] `utils` folder filled with utility examples like `embed pagination`, `date formatter`, `validators`, `etc...`
## Get started π
- **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 **recommended**
- `pm2` - not required but **recommended**
- `npm install pm2 -g` *to install it globally*
- `nodemon` - not required but **recommended**
- `npm 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`](https://github.com/miguelmikkey/discordjs-bot-template/blob/main/INSTALLATION.md)
- π locale (*Multiple languages*) [`./locales/README.md`](https://github.com/miguelmikkey/discordjs-bot-template/tree/main/locales/README.md)
- Discord.js [Guide](https://discordjs.guide/#before-you-begin)
## Contributing πββοΈ
- 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!**
## Useful docs π
- [Mongoose docs](https://mongoosejs.com/docs/) *MongoDB*
- [PM2 docs](https://pm2.keymetrics.io/docs/usage/quick-start/)
- [PermissionFlags](https://discord-api-types.dev/api/discord-api-types-v10#PermissionFlagsBits)
- [SlashCommands](https://discordjs.guide/slash-commands/response-methods.html)
- [EmbedBuilder](https://discordjs.guide/popular-topics/embeds.html)
- [ButtonBuilder](https://discordjs.guide/message-components/buttons.html)
- [ModalBuilder](https://discordjs.guide/interactions/modals.html#building-and-responding-with-modals)
- [SelectMenus](https://discordjs.guide/message-components/select-menus.html#building-string-select-menus)
- [Cooldowns](https://discordjs.guide/additional-features/cooldowns.html#resulting-code)
- [Sharding](https://discordjs.guide/sharding/#when-to-shard)
- [OAuth2](https://discordjs.guide/oauth2/#a-quick-example)
## License
This project is licensed under the [MIT](https://github.com/miguelmikkey/discord-bot-template/blob/main/LICENSE) License.