1.0.6 • Published 2 years ago

@dtsjs/djs-handler v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3-4

2 years ago

1.0.3-3

2 years ago

1.0.3-2

2 years ago

1.0.3-1

2 years ago

1.0.3-0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago