slashctrl
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

SlashCtrl

Tests Status NPM npm Issues npm Discord

NPM

SlashCtrl is a package that makes it easier to create and manage slash commands with DiscordJS.

Join the discord: https://discord.gg/4g7sznXvXX

Features

  • Easy to use
  • Fast and reliable
  • Integrated with DiscordJS

SlashCtrl creates a simple framework to easily create and manage slash commands with DiscordJS, it also handles all the necessary checks for you, so you don't have to worry about that.

Installation

To install, simply run the following command:

npm install slashctrl

or

yarn add slashctrl

or

pnpm add slashctrl

Usage

First, you'll need to initialize the SlashCtrl class, like so:

const { SlashCtrl } = require('slashctrl');

const slashCtrl = new SlashCtrl({
    token: 'your bot token',
    applicationId: 'your bot application id'
});

Then, you'll need to register your commands, you can use the publishCommandsFromFolder method to do so:

slashCtrl.publishCommandsFromFolder(path.join(__dirname, 'commands'));

Here is an example of a command file

export default class ExampleCOmmand extends SlashCommand {

    constructor() {
        super();
        this.setName("example");
        this.setDescription("This is an example command");
    }

}

Since the SlashCommand class extends DiscordJS's SlashCommandBuilder, you can use all of its methods to build your command.

Finally, SlashCtrl will need to know when to execute your commands, you can do so by using the handleCommands method in your InteractionCreate event, the package will take care of the rest and necessary checks:

client.on('interactionCreate', async interaction => {
    slashCtrl.handleCommands(interaction);
});

That's it! You're all set up!

NOTE: SlashCtrl is still being worked on with more features coming. Some features may not be fully implemented yet.

Package Sidebar

Install

npm i slashctrl

Weekly Downloads

62

Version

0.2.1

License

MIT

Unpacked Size

18.7 kB

Total Files

21

Last publish

Collaborators

  • orbitalbrain