Skip to content

export abstract Class

Command ​

extends ​

Piece<CommandMeta>

A command piece.

Constructor ​

ts
 new Command( context_piece, context_metadata )
ParameterTypeDescription
context_piecePieceContext
context_metadataCommandMeta

Properties ​

get enabled : boolean ​

chat_groups? : Object ​

The chat ids along with their member ids to attach to the scope.

chat_ids? : number[] ​

The chat ids to attach to the scope.

readonly client : Client ​

command? : string ​

The command that is attach to this piece.

description? : string ​

The description of the command.

emitter : any ​

ignore : boolean ​

Wether to ignore the piece if it has been registered for faster intializing.

language_code : string | Object ​

A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands

name? : string ​

registry : CommandsRegistry ​

scope : CommandScopeType ​

The scope of the command, see <TelegramAPI#BotCommandScope> .

Methods ​

getCommand( identifier ) ​

ParameterTypeDescription
identifier?stringIf you have multiple language code, this can be the name or the language code. Otherwise returns the command from this.

Gets the command. If the command cannot be found, it will return an empty object.

Returns: Partial<BotCommand>

listen( ) ​

Activates or resumes the listener, this is activated on load.

Returns: void

run( ...args ) ​

ParameterTypeDescription
...argsunknown[]

Returns: unknown

stop( ) ​

Stops the listener.

Returns: void

A modern, powerful library for building your Telegram bots, with seamless support for both JavaScript and Typescript.