The simplified and popular Discord bot commands & events handler built with discord.js version 14 and written in JavaScript. This handler can load up to 4 different type of commands; Prefix, Slash, User context and Message context. It can also handles components; Buttons, Modal submits, Select menus (any type).
Did you like my project? Click on the star button (⭐️) right above your screen, thank you!
Looking for the old version? Click here.
- Supports all possible type of commands.
- Message commands (AKA: Prefix commands).
- Application commands:
- Chat Input
- User context
- Message context
- Components Handler.
- Buttons
- Select menus
- Modals
- Easy and simple to use.
- Advanced command options (click here).
- Updated to latest discord.js version.
- Included a database: MongoDB.
Note This handler uses CommonJS modules system.
module.exports = {
structure: {
name: string,
description: string,
aliases: string[],
permissions?: PermissionFlagsBits | string,
cooldown?: number,
developers?: boolean,
nsfw?: boolean
},
run: async (client, message, args) => Promise<void>
};
module.exports = {
structure: SlashCommandBuilder | ContextMenuCommandBuilder,
options?: {
cooldown?: number,
developers?: boolean,
nsfw?: boolean
},
run: async (client, interaction) => Promise<void>
};
module.exports = {
event: string,
once?: boolean,
// '...args' are the arguments of the event chosen (from discord.js).
run: async (client, ...args) => Promise<void>
};
module.exports = {
customId: string,
// 'interaction' is the interaction of the component. If the custom ID is from a button, the interaction is type of ButtonInteraction.
run: async (client, interaction) => Promise<void>
};
- chalk v2.4.2
- discord.js v^14.13.0
- dotenv v^latest
- mongoose v^latest
Warning Installing any version from the package
chalk
that is over v2.4.2, it will throw an error that you must enable ES6 modules, while this handler uses CommonJS modules.
- Node.js v16.9.0 or newer
- Install Visual Studio Code.
- Download this project as a .zip file: Click here
- Extract the .zip file into a normal folder.
- Open VSCode, click on Open Folder, and select the new created folder.
- Go to
src/
and renameexample.config.js
toconfig.js
and fill all the required values.
module.exports = {
client: {
token: string, // ← Your bot token (USE .env IS RECOMMENDED)
id: string // ← Your bot ID (USE .env IS RECOMMENDED)
},
handler: {
prefix: string, // ← The bot prefix
deploy: boolean, // ← Always load application commands to Discord? (true: Yes, false: No)
commands: {
prefix: boolean, // ← Toggle prefix commands
slash: boolean, // ← Toggle slash commands
user: boolean, // ← Toggle user commands
message: boolean // ← Toggle message commands
},
mongodb: {
uri: string, // ← Your MongoDB URI string (USE .env IS RECOMMENDED)
toggle: boolean // ← Connect to the database or not? (true: Yes, false: No)
}
}
}
You can use ENV instead of config.js
to keep your bot token and ID and your MongoDB URI in a safe place. Rename the file .env.example
to .env
and fill all the required values.
CLIENT_TOKEN = Your bot token
CLIENT_ID = Your bot ID
MONGODB_URI = Your mongodb URI string
- Initialize a new package and install all required packages:
npm init -y
npm install [email protected] discord.js dotenv mongoose
- To start your bot, run
node .
ornpm run start
. - Enjoy. =)
Use Discloud! A trust-worthy Discord bot hosting service.
- Login using your Discord/GitHub account, and then don't close the Dashboard tab (because we need it later).
- Go to your project on VSCode, create a new file
discloud.config
. This file is a configuration file for Discloud apps servers. Thediscloud.config
file content must be like the codeblock below, and remember to change YOUR_BOT_ID to your actual bot ID.
ID = YOUR_BOT_ID
TYPE = bot
MAIN = src/index.js
RAM = 100
AUTORESTART = true
VERSION = latest
API = tools
- Open explorer and navigate using the path of your project. Hold the CTRL key, and click on
src/
,package.json
, anddiscloud.config
. Now release the key, and right click on the selected files/folders and click on Convert into .zip file. - Go back to the Discloud dashboard, click on Add App, and then upload the .zip file in the upload box. Make sure to accept the ToS of the service and then click on Upload.
- Wait for at least 20 seconds (depends on your Internet speed), and then your bot should be on.
Warning Discloud has recently made every Free plan servers into 15 days hosting only. Use the command
.rw
from their bot in the commands channel (on their Discord server) to reset the timer. Join the server: Click here!
The command options, each property is optional, which means it's allowed to provide an undefined
value to one of these properties below.
permissions
(PermissionFlagsBits | string): The required permissions for the command, available to message commands only.cooldown
(number): The cooldown of the command, in milliseconds.developers
(boolean): Whenever the command is executable only to the developers of the bot.nsfw
(boolean): Whenever this command is executable only in NSFW channels.
Thank you to all the people who contributed to DiscordJS-V14-Bot-Template!
Join our Discord server if you need any help!
This error only hapens if your bot token and bot ID are not from the same bot. For an example, if you get a bot token from a bot, and a bot ID from another bot, this will throw the error. If you get the token and the ID from the same bot, it will return no errors.
No, MongoDB is not required. There is an option to disable it in config.js
so you will avoid errors from the commands that requires the database, such as ?prefix
. If you want to use the database, visit MongoDB website.
GPL-3.0, General Public License v3