A discord bot template that handles slash commands and interactions, with dynamic module loading.
Find a file
2022-09-26 20:30:32 -04:00
.vscode qol changes 2022-09-18 14:52:19 -04:00
bot Merge branch 'main' of https://github.com/gurrrrrrett3/discord-bot-template 2022-09-26 20:30:32 -04:00
prisma update template 2022-09-26 20:30:21 -04:00
scripts oops again :) we good now 2022-09-18 14:08:06 -04:00
.env.template base template 2022-08-17 13:17:31 -04:00
.gitattributes Initial commit 2022-08-17 02:03:00 -04:00
.gitignore Initial commit 2022-08-17 02:03:00 -04:00
CONTRIBUTING.md qol changes 2022-09-18 14:52:19 -04:00
index.ts base template 2022-08-17 13:17:31 -04:00
LICENSE Initial commit 2022-08-17 02:03:00 -04:00
package-lock.json Module/command loading and unloading 2022-09-17 03:05:46 -04:00
package.json Module/command loading and unloading 2022-09-17 03:05:46 -04:00
README.md qol changes 2022-09-18 14:52:19 -04:00
tsconfig.json base template 2022-08-17 13:17:31 -04:00

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

  1. Clone the repository
  2. Run npm install in the root directory
  3. Copy the .env.template file to .env and fill in the values
  4. Run tsc to compile
  5. Run node . to start the bot

How to create a module

node ./scripts/createModule.js <name> <description>

Creating a command

  1. Create a new file in the bot/modules/<module>/commands directory
  2. Use the command snippet

Creating a context menu command

  1. Create a new file in the bot/modules/<module>/commands directory
  2. Use the userContextMenu or messageContextMenu snippet

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