A discord bot template that handles slash commands and interactions, with dynamic module loading.
| .vscode | ||
| bot | ||
| prisma | ||
| scripts | ||
| .env.template | ||
| .gitattributes | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| index.ts | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
Discord Bot Template
This template was originally made by me to stop having to rewrite boilerplate code for every bot I make. It's expanded a lot since then, and I've done my best to make it as easy to use as possible.
Table of Contents
Features
- Command handler
- Designed to be Modular
- Custom Command Builder
- Slash Command Support
- Context Menu Support
- Autocomplete support
- Button, Select Menu, and Modal event handling
Installation
- Clone the repository
- Run
npm installin the root directory - Copy the
.env.templatefile to.envand fill in the values - Run
tscto compile - Run
node .to start the bot
How to create a module
node ./scripts/createModule.js <name> <description>
Creating a command
- Create a new file in the
bot/modules/<module>/commandsdirectory - Use the
commandsnippet
Creating a context menu command
- Create a new file in the
bot/modules/<module>/commandsdirectory - Use the
userContextMenuormessageContextMenusnippet
Registering a button, select menu, or modal
import { bot } from "../../.."; // Import the bot from the root directory
bot.buttonManager.registerButton("customId", async (interaction) => {
// Do something
});
bot.selectMenuManager.registerSelectMenu("customId", async (interaction) => {
// Do something
});
bot.modalManager.registerModal("customId", async (interaction) => {
// Do something
});
Unregistering a button, select menu, or modal
import { bot } from "../../.."; // Import the bot from the root directory
bot.buttonManager.unregisterButton("customId");
bot.selectMenuManager.unregisterSelectMenu("customId");
bot.modalManager.unregisterModal("customId");
Contributing
If you have any suggestions, feel free to open an issue or pull request.
License
This project is licensed under the MIT License.
Credits
- Discord.js - The Discord API wrapper used
- Chalk - Used for nice console logging