1.0.2 • Published 1 year ago

@traid/command-handler v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

@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]);
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago