nestjs-telegraf/lib/decorators/command.decorator.ts
2020-08-14 12:42:57 +03:00

26 lines
624 B
TypeScript

import { SetMetadata } from '@nestjs/common';
import { DECORATORS } from '../telegraf.constants';
export type TelegrafCommandCommands = string | string[];
export interface CommandOptions {
commands: TelegrafCommandCommands;
}
/**
* Command handling.
*
* @see https://telegraf.js.org/#/?id=command
*/
export const Command = (commands: TelegrafCommandCommands): MethodDecorator => {
return SetMetadata(DECORATORS.COMMAND, { commands });
};
/**
* Command handling.
*
* @see https://telegraf.js.org/#/?id=command
* @deprecated since v2, use Command decorator instead.
*/
export const TelegrafCommand = Command;