This repository contains a bot template for discord.js@v14
. It use external handler (developped by cleboost djs-core
ans some submodule). The bot is designed with a handler to easily create commands, buttons, selections and other fun interactions.
Before using this bot, make sure you have:
- Node.js (min v18): To develop and run the script.
- Javascript IDE: A development environment to edit the code like Visual Studio Code (free), WebStorm (paid).
- Clone this repository to your local system.
- Open the project in your development environment.
- Go to
src/
folder, it contains the main bot script. - Edit
.env
with your bot token. - Customize
config.ts
with your settings (optional). - Install NPM package with
pnpm i
command (you can usenpm i
oryarn
butpnpm
is recommended). - Start bot with
pnpm run start
(ornpm run start
oryarn run start
).
- Build the project with
pnpm run build
(you can customize build options in build script inpackage.json
for obfuscation, etc.) - You can now run the bot with
node dist/index.js
- If you use prisma, be sure to run
npx prisma generate
before building and copy theprisma
& node_modules folders to thedist
folder - You can also get all content of the
dist
folder and put it in a zip file to deploy it on a server
This project includes Sqlite natively and exemples of usage in the commands. You can use it to store data, like user's money, server's settings, etc.
📚 /help Dynamically generates help message with existing commands(in redev)⛔ /stop Stops the bot (admin command)🧪 /test Empty command for testing purposes (devOnly command)- 🏓 /ping Displays bot latency (in ms)
- Example commands for various options
- Admin category commands are not shown in /help and require being registered (Discord ID) in the
config.json
owner array 👑 - Commands marked as
devOnly: true
require being a developer to execute and should be registered in theconfig.json
dev array 💻 - Configurations are cached in the client, accessible by
client.config
- DB is cached in the client, accessible by
client.db
- Cooldown is in seconds but resets on each bot restart; it's disabled for devOnly commands ⏱️
- You can launch the bot with
npm run dev
, in which case the bot restarts with each save you make, otherwise usenode index.js
ornpm run start
- Buttons and commands can have categories: create a folder and place the file inside (see examples)
- Debug mode enabled by default, configuration in
.env
This projet allow you to create sub command like /command subcommand
. To do it, you can check exemple in src/interactions/commands/utils/handler.ts
and src/interactions/commands/utils/handler/button.ts
As you can see, you need to create the regitred command where you define name of your command, description, default permission, sub command. In subfolder with same name of your command, you can create subcommand. Subcommand files need to have same name of the subcommand.
Contributions are welcome! If you want to improve this bot or add new features, feel free to submit a pull request.
This project is licensed under MIT - see the LICENSE link for more details. 📜