No description
Find a file
2022-09-25 13:31:09 -04:00
.vscode Initial commit 2022-09-25 13:31:09 -04:00
bot Initial commit 2022-09-25 13:31:09 -04:00
scripts Initial commit 2022-09-25 13:31:09 -04:00
.env.template Initial commit 2022-09-25 13:31:09 -04:00
.gitattributes Initial commit 2022-09-25 13:31:09 -04:00
.gitignore Initial commit 2022-09-25 13:31:09 -04:00
CONTRIBUTING.md Initial commit 2022-09-25 13:31:09 -04:00
index.ts Initial commit 2022-09-25 13:31:09 -04:00
LICENSE Initial commit 2022-09-25 13:31:09 -04:00
package-lock.json Initial commit 2022-09-25 13:31:09 -04:00
package.json Initial commit 2022-09-25 13:31:09 -04:00
README.md Initial commit 2022-09-25 13:31:09 -04:00
tsconfig.json Initial commit 2022-09-25 13:31:09 -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