Discord Handler
About This Handler
The Ultimate Discord.js Handler Template which handles fast and effectively Commands and Events.
This project was written using typescript Which may help you get help when using the code editor.
Features
- prefix command handler
- message command handler
- user command handler
- buttons handler
- select menu handler
- modal handler
- kmcodes message manager
- discord.js@14.3.0
install and run
Download the project and extract the files, then go to the extracted file
or you can download the project using git
git clone https://github.com/KMKINGMAN/discord-handler.git
cd discord-handlerOpen Terminal/shell or cmd and download the packages via the command
npm installNow create an .env file and put your bot informationon it or just use src/config.json file
token=BOT_TOKEN
prefix=BOT_PREFIX
mongo=MONGO DB CONNECTION LINK
client_id=YOUR_BOT_IDStart the project using
npm startHow to use the events handler
Go to src/events/ Create a single group by creating a new folder
Go to the folder and then create a new file that should end in typescript
for example src/events/start/ready.ts
now paste a template for events handler
import { EventsTyper } from "../../lib/handler/events";
export let events = {
name: "", // event name
async run(client){ // event callback
//You Code Here
}
} as EventsTyper;How to use the command handler
Go to src/commands/ Create a single group by creating a new folder
Go to the folder and then create a new file that should end in typescript
for example src/commands/start/hello.ts
now paste a template for command handler
prefix command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
general: {
name: "", // command name
async run(client, message, args, manager) {//Callbak
//Your Code Here
},
}
} as CommandFilerTypemessage command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
message_command: {
id: "", // command id
async run(client, interaction) {
//Your Code Here
},
},
} as CommandFilerTypeslach command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
slachcmd: {
name: "", //Command Name
description: "", // Command des
permissions: { // You can use it or just remove it
me: "",
bot: ""
},
options: [], // [<ApplicationCommandOptionData>]You Can use it or just remove it
async run(client, interaction) {
//Your Code Here
})
},
},
} as CommandFilerTypeuser command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
user_command: {
id: "",//Command id
async run(client, interaction){
//Your Code
}
},
} as CommandFilerTypemodal command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
modal: {
id: "",//Command ID
async run(client, interaction) {
//Your Code Here
},
},
} as CommandFilerTypeselect_menu command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
select_menu: {
id: "",//Commad ID
async run(client, interaction) {
//Your Code Here
},
},
} as CommandFilerTypebuttons command template
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } from "discord.js";
import { CommandFilerType } from "../../lib/handler/command";
export let command = {
buttons: [{ // ITS ARRAY YOU CAN USE MORE THAN ONE BTN
id: "",//Button id
async run(client, interaction) {
//Your Code Here
},
}]
} as CommandFilerTypeYou can use them all in one file see src/commands/test/test-message.ts

