Text Commands
Create a simple command handler for messages using @TextCommand
.
src/app.service.ts
import { Injectable } from '@nestjs/common';
import { Context, TextCommand, TextCommandContext, Arguments } from '@nestgramjs/core';
@Injectable()
export class AppService {
@TextCommand({
name: 'start',
description: 'Start command!',
})
public onStart(@Context() [message]: TextCommandContext) {
return message.reply('Start command triggered!');
}
}
src/app.service.ts
import { Injectable } from '@nestjs/common';
import { Context, TextCommand, CommandContext } from '@nestgramjs/core';
@Injectable()
export class AppService {
@TextCommand({
name: 'start',
description: 'Start command!',
})
public onStart(@Context() [ctx]: TextCommandContext) {
return ctx.reply('Start command triggered!');
}
}
If all goes well, you should see something like this: