@traid/command-handler

1.0.2 • Public • Published

@traid/command-handler

This package provide a Slash Command Handler for discord.js V13

Installation

To use this package, you must have Node.js installed on your system. You can install this package by running the following command in your terminal :

npm install @traid/command-handler

Usage

Importing the package

import { Client } from "discord.js";
import { SlashCommandHandler } from "@traid/command-handler";

Creating a command

import { SlashCommandBuilder, type CommandInteraction } from "discord.js";
import { Command } from "@traid/command-handler";

export class PingCommand extends Command {
  public data = new SlashCommandBuilder()
    .setName("ping")
    .setDescription("pong");

  public async execute(interaction: CommandInteraction): Promise<void> {
    await interaction.reply("pong !");
  }
}

Handling commands

The handleCommands method is used to handle commands by giving him the commands objects you want to handle. You can use this method like this :

import { PingCommand } from "@/commands/Ping.command.ts";
slashCommandHandler.handleCommands([PingCommand]);

Package Sidebar

Install

npm i @traid/command-handler

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

4.48 kB

Total Files

6

Last publish

Collaborators

  • geloocg