Skip to content
/ CommandHandlerTs Public template

An advanced handler for typescript. Using as dependency. Discord.js

License

Notifications You must be signed in to change notification settings

Chere3/CommandHandlerTs

Repository files navigation

handler_typescript

Multiple command handler for typescript.
By: Cheree

Features:

  • Have support to slash commands.
  • Works with discord.js V13.
  • Typescript version.
  • Has updated documentation for all types of users.
  • Multillang.

Options for commands

Name

This is the name of the command, all answers of messages with <prefix><name of command> returns the code of this, is recommended to are only a one word, this is a String

name: String
name: "ping"

Description

The description of the command, this returns the description of the command, is util to help command. This a String

description: String
description: "Ping command"

Aliases

The aliases for the command, if the command name not found, search in aliases of the command to return that answer. This a Array

aliases?: String[]
aliases?: ["pong", "status"]

Category

The category of the command, if dont have category, is changed with bot. This a String

category?: String
category?: "bot"

Dev

Defines if the command, are disponible to everyone or the owners defined in src/config.ts. This a Boolean.

dev?: Boolean
dev?: false

NSFW

Defines if the command, can be executed in only nsfw channels of no. This a Boolean.

nsfw?: Boolean
nsfw?: false

Cooldown

The cooldown of the command, if the user is not a developer returns a message with the cooldown of the mentioned seconds, this a Number

cooldown?: Number
cooldown?: 10

botPermissions

The bot detects if have one or the permissions of the Array can be executed, if i dont have one of the permissions, return a message saying that the bot has not have permissions.

 botPermissions?: PermissionString[]
 botPermissions?: ["SEND_MESSAGES", "MANAGE_MESSAGES"]

botPermissions

The bot detects if the user that execute the command have one or the permissions of the Array can be executed, if user dont have one of the permissions, return a message saying that the bot has not have permissions.

 botPermissions?: PermissionString[]
 botPermissions?: ["MANAGE_GUILD"]

usage

The usage of the command, the excellent Method for documentation.

usage?(prefix: String): String
usage("!")ping

example

The example of the command, the excellent Method for documentation.

usage?(prefix: String): String
usage("!")ping

Example of a command

import { TempContext } from "../../Util/Classes/Context";
import { BaseCommand } from "../../Util/Classes/BaseCommand";
import { Client } from "discord.js";
import { MessageEmbed } from "discord.js";

export default class PingCommand extends BaseCommand {
  constructor(client: Client) {
    super(client, {
      name: `ping`,
      description: `Test the bot`,
      guildOnly: false,
      dev: true,
      usage: (prefix: "!")ping,
      example: (prefix: "!")ping
    });
  }

  async run(base: TempContext) {
    base.channel.send(`pong!`)
  }
}