Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CommandModule

Defines a command that users can send to the bot. Commands must begin with a prefix that can be configured globally, or on a per-chat-thread or per-user basis.

Unless configured, the default prefix is '#'. An example command would be '#help'.

since

2.0.0

Hierarchy

Implemented by

Index

Methods

execute

  • execute(msg: Message, args: string): Promise<any>
  • The method that gets executed when the received message is a valid command.

    abstract
    since

    2.0.0

    Parameters

    • msg: Message

      The received message object.

    • args: string

      String containing everything after the command. For example, if the message is "#quote me", this parameter will be "me".

    Returns Promise<any>

getCommand

  • getCommand(): string | string[]
  • Returns the command(s) this module acts on. String(s) should not include the command prefix.

    abstract
    since

    2.0.0

    Returns string | string[]

    the command(s)

getDescription

  • getDescription(): string

getRuntime

getUsage

  • getUsage(): string
  • Returns a user-friendly description of the arguments this command accepts. This is used in descriptions and error messages.

    abstract
    since

    2.0.0

    Returns string

onListen

  • onListen(): Promise<any>

onShutdown

  • onShutdown(): Promise<any>

validate

  • validate(msg: Message, args: string): boolean
  • Validates the message containing the command. If this returns true, the execute() method will be invoked. If this returns false, an error message with the correct usage of the command will be sent to the chat.

    abstract
    since

    2.0.0

    Parameters

    • msg: Message

      The received message object.

    • args: string

      String containing everything after the command. For example, if the message is "#quote me", this parameter will be "me".

    Returns boolean

    true if the command is valid and should be executed, false otherwise.

Generated using TypeDoc