Handling commands
Handle when user writes a command (e.g. /start, /help, /menu)
Handle command
To handle a command, you can use @OnCommand
decorator
Get command params
You can get command params too (e.g. when user writes /start hello or follows the bot link with some params). Use @CommandParams
property decorator to it
Example
import { OnCommand, Controller, CommandParams } from 'nestgram';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService?: AppService) {}
@OnCommand('start')
async start(@CommandParams() params: string[]): Promise<string> {
console.log(params);
return 'Hello, world!';
}
}
Last updated