A slash command requires this command class!

import { CommandContext, SlashCommand } from "discord-interactionhandler-js";

class SayCommand extends SlashCommand {
get name() {
return "say";
}

get description() {
return "This is a say command!"
}

get options() {
return [
{
type: 3,
name: "string",
description: "This is a string!",
required: true
}
];
}

get version() {
return "1.0.0";
}

async run(ctx: CommandContext) {

let string = ctx.options.getString("string");
ctx.interaction.reply({ content: string || undefined, fetchReply: true });

}
}

Hierarchy (view full)

Constructors

Accessors

  • get description(): string
  • This function set the command description!

    Returns string

    The function must be return a string!

  • get guildOnly(): boolean
  • This function restrict the command usage to guilds only!

    Returns boolean

    The function must be return a boolean!

    false
    
  • get version(): string
  • This function set the version of the command!

    Returns string

    The function must be return a string!

    "1.0.0"
    

Methods

  • This function can be used in to send a error message in discord!

    Parameters

    • interaction: CommandInteraction<CacheType>
    • error: string

    Returns Promise<InteractionResponse<boolean>>

    The function returns the error reply!