1.2.1 • Published 4 years ago
@mycool/discordjs-slashcommand v1.2.1
Discordjs-SlashCommand
Discordjs-SlashCommand is a npm library. this library make slash command easer
Installation
npm install @mycool/discordjs-slashcommands --saveUsage
const Discord = require('discord.js');
const client = new Discord.Client({
intents: Object.values(Discord.Intents.FLAGS)
});
const package = require('@mycool/discordjs-slashcommands');
const builder = new package.CommandBuilder(client);
client.once('ready', () => {
console.log('The bot is ready')
builder.build([
{
global: true,
command: {
type: 'CHAT_INPUT',
name: 'test',
description: 'testing the package.',
},
commandResponse: {
async CommandExec(interaction) {
interaction.reply({
content: 'test',
ephemeral: true
})
}
},
}
]).then(() => {
builder.run();
});
})
client.login('TOKEN_HERE')Options
CommandBuilder
@parmsclient@typeof {client}<discord.js>.Client
CommandBuilder/__client__
@type<discord.js>.Client- the client that
CommandBuilderusing.
CommandBuilder/__Commands__
@typeMap<string, BuildData>- the commands that
CommandBuilderusing.
CommandBuilder/__ComponentDir__
@typestring- the
Componentsfolder thatCommandBuilderusing - default -
null
CommandBuilder/setComponent
@parmspath@typeof {path}string- The folder should look like this:
__dirname ├───Buttons │ ├───ButtonCustomId.js/ts │ └───... └───SelectMenu ├───SelectMenuCustomId.js/ts └───... - If component message is from interaction you don't need to create a file in this folder you can use the function in the build function him self
CommandBuilder/build
@parmsDatatypeof {Data}BuildData[]- Build the slash command/s.
CommandBuilder/run
- Runing the slash command/s.
CommandBuilder/reset
- removing all global client slash commands.
CommandBuilder/remove
@parmsglobal@typeof {global}boolean@parmsguildId@typeof {guildId}<discord.js>.Snowflake@parmsCommandName@typeof {CommandName}string