@dtsjs/djs-handler
v1.0.6
Published
manage your slash command easily with djs cmd handler
Downloads
34
Readme
About
djs-handler is powerful module for creating and managing Discord.js slash commands, events, etc.
- Easy to Use
- Write bot in minimum lines of code
- Support Slash Commands, Slash Command options
Installation
npm i @dtsjs/djs-handler
Example Usage
Directory tree
discord-bot/
├── ...
├── index.js
├── events
│ ├── ...
│ └── ready.js
├── commands
│ ├── ...
│ └── info
│ ├── ...
│ └── ping.js
└── ...
Main File
const { Client, Intent } = require("discord.js");
const { Handler } = require("@dtsjs/djs-handler");
const client = new Client({ intents: [Intent.FLAGS.GUILD] });
client.once("ready", () => {
console.log("Ready!");
new Handler(client, {
commandFolder: "commands",
registerCommands: true,
deferReply: false,
// guilds: ['123456789012345678'], # Optional - Only register commands for these guilds
});
});
client.login("token");
Command File
module.exports = {
name: 'ping',
description: 'Ping!',
//optional - this is example of command options
options: {
string: [
{
name: 'string_choices_name', description: 'option string with choices',
required: false,
choices: [
{ name: 'choice 1', value: 'ch1' },
{ name: 'choice 2', value: 'c2' }
]
},
{ name: 'string_name', description: 'option string', required: false }
],
user: [
{ name: 'user_name', description: 'user input', required: false }
],
channel: [
{ name: 'channel_name', description: 'channel input', required: false }
],
role: [
{ name: 'role_name', description: ' role input', required: false }
]
}
run(client, interaction) {
const user = interaction.options.getUser('user_name')
interaction.reply(`Pong! ${user.username}`);
}
}
Event File
module.exports = {
name: 'ready',
run async (client) {
console.log(`Bot is ready!`);
}
}
Help
If you don't understand how to use this module, please check out the documentation or join the discord server