djs-slash-cmd-handler
About
djs-slash-cmd-handler is a small module made to simplify the tasks with the slash commands.
Installation
discord.js 14.2.0 or newer is required.
npm i --save djs-slash-cmd-handler
Example usage
Registering a command
const { SlashCommandBuilder } = require('discord.js');
const { CommandDeployer } = require('djs-slash-cmd-handler');
const deployer = new CommandDeployer('<BOT_TOKEN>', '<APPLICATION_ID>');
const command = new SlashCommandBuilder()
.setName('ping')
.setDescription('returns pong')
deployer.set(command);
deployer.deploy();
Handling commands with a bot
const { Client } = require('discord.js');
const { CommandHandler } = require('djs-slash-cmd-handler');
const client = new Client({ intents: [] });
const handler = new CommandHandler(client);
handler.set('ping', (interaction) => {
interaction.reply('pong');
});
client.login('<BOT_TOKEN>');
Links
Help
If you don't understand something, have a question or just want to know which is the right path, don't hesitate to join our server.