My commands

You can set/delete/get my bot commands

Set my commands

To set my commands, use MyCommands class-method or .setMyCommands answer/api method

MyCommands class-method take arguments:

Argument
Description
Required
1

Required

2

Optional

3

Language code

Optional

If you want to know what arguments an API method takes, see the IDE hint

Delete my commands

To delete my commands, use DeleteMyCommands class-method or .deleteMyCommands answer/api method

DeleteMyCommands class-method or .deleteMyCommands answer method take arguments:

Argument
Description
Required
1

Optional

2

Language code

Optional

If you want to know what arguments an API method takes, see the IDE hint

Get my commands

To get my commands, use .getMyCommands answer/api method

.getMyCommands answer method take arguments:

Argument
Description
Required
1

Optional

2

Language code

Optional

Returns array of IBotCommand on success

If you want to know what arguments an API method takes, see the IDE hint

Example

app.controller.ts
import { Controller, OnCommand, MyCommands, DeleteMyCommands, GetAnswer, Answer } from 'nestgram';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @OnCommand('start')
  setMyCommands() {
    return new MyCommands([
      { command: 'start', description: 'Start bot' },
      { command: 'help', description: 'Get help' },
    ]).next('My commands updated!');
  }

  @OnCommand('delete_commands')
  deleteMyCommands() {
    return new DeleteMyCommands();
  }

  @OnCommand('get_commands')
  async getMyCommands(@GetAnswer() answer: Answer) {
    console.log(await answer.getMyCommands());
    return 'Logged to console';
  }
}

Last updated