A Discord bot commands, components and events handler based on discord.js v14 and fully written in JavaScript.
Did you like the project? Click on the star button (⭐️) right above your screen, thank you!
- Updated to the latest version of discord.js v14.x.
- Supports all possible type of commands.
- Message commands.
- Application commands:
- Chat Input
- User context
- Message context
- Handles components.
- Buttons
- Select menus
- Modals
- Autocomplete
- Easy and simple to use.
- Advanced command options.
- Simple Database included (YAML).
Partial
.
Awaitable
means the function might be async.
new MessageCommand({
command: {
name: string, // The command name
description?: string, // The command description (optional)
aliases?: string[], // The command aliases (optional)
permissions?: PermissionResolvable[], // The command permissions (optional)
},
options?: Partial<{
cooldown: number, // The command cooldown, in milliseconds
botOwner: boolean, // Bot owner can only run it? (true = yes, false = no)
guildOwner: boolean, // Guild owner can only run it? (true = yes, false = no)
botDevelopers: boolean, // Bot developers can only run it? (true = yes, false = no)
nsfw: boolean // The command contains NSFW content? (true = yes, false = no)
}>,
run: Awaitable<(client: DiscordBot, message: Message, args: string[]) => void> // The main function to execute the command
});
APIApplicationCommand
, Partial
.
Awaitable
means the function might be async.
new ApplicationCommand({
command: APIApplicationCommand,
options?: Partial<{
cooldown: number, // The command cooldown, in milliseconds
botOwner: boolean, // Bot owner can only run it? (true = yes, false = no)
guildOwner: boolean, // Guild owner can only run it? (true = yes, false = no)
botDevelopers: boolean, // Bot developers can only run it? (true = yes, false = no)
}>,
run: Awaitable<(client: DiscordBot, interaction: Interaction) => void> // The main function to execute the command
});
Awaitable
means the function might be async.
new AutocompleteComponent({
commandName: string,
run: Awaitable<(client: DiscordBot, interaction: AutocompleteInteraction) => void> // The main function to execute the command
});
Partial
.
Awaitable
means the function might be async.
new Component({
customId: string,
type: 'modal' | 'select' | 'button',
options?: Partial<{
public: boolean // Other users can use the main interaction author button/select? (true = yes, false = no)
}>
run: Awaitable<(client: DiscordBot, interaction: Interaction) => void> // The main function to execute the command
});
Awaitable
means the function might be async.
K
is a type parameter, extends keyof ClientEvents
.
new Event({
event: K,
once?: boolean, // The event can only happen once? (true = yes, false = no)
run: Awaitable<(client: DiscordBot, ...args: ClientEvents[K]) => void>
});
- colors → latest
- discord.js → 14.13.0 or newer
- dotenv → latest
- quick-yaml.db → latest
Note
Node.js v16.11.0 or newer is required to run discord.js.
- Install a code editor (Visual Studio Code for an example).
- Download this project as a .zip file: Download
- Extract the .zip file into a normal folder.
- Open your code editor, click on Open Folder, and select the new created folder.
- Rename the following files:
src/example.config.js
→src/config.js
: Used for handler configuration..env.example
→.env
: Used for secrets, like the Discord bot token.example.database.yml
→database.yml
: Used as a main file for the database.example.terminal.log
→terminal.log
: Used as a clone of terminal (to save previous terminal messages).
- Fill all the required values in config.js and .env.
Caution
Please remember not to share your Discord bot token! This will give access to attackers to do anything they want with your bot, so please keep the token in a safe place, which is the .env file.
-
Initialize a new project:
npm init
(To skip every step, donpm init -y
). -
Install all required dependencies:
npm install colors discord.js dotenv quick-yaml.db
-
Run the command
node .
ornpm run start
to start the bot. -
Enjoy! The bot should be online.
Feel free to fork the repository and submit a new pull request if you wish to contribute to this project.
Before you submit a pull request, ensure you tested it and have no issues. Also, keep the same coding style, which means don't use many unnecessary spaces or tabs.
Thank you to all the people who contributed to DiscordJS-V14-Bot-Template!
Join our Discord server if you have any questions to ask, or if you have a problem with this project, you can go to the issues section and submit a new issue.
GPL-3.0, General Public License v3