# My commands

## Set my commands

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

#### MyCommands class-method take arguments:

<table><thead><tr><th width="204.09829867674864" data-type="number">Argument</th><th width="305.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td>Commands you want to set (<strong>array of</strong> <a href="https://core.telegram.org/bots/api#botcommand"><em>IBotCommand</em></a>)</td><td><strong>Required</strong></td></tr><tr><td>2</td><td><a href="https://core.telegram.org/bots/api#botcommandscope">Scope</a> for which you want to set commands to</td><td>Optional</td></tr><tr><td>3</td><td>Language code</td><td>Optional</td></tr></tbody></table>

{% hint style="info" %}
If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

## 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:

<table><thead><tr><th data-type="number">Argument</th><th width="331.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td><a href="https://core.telegram.org/bots/api#botcommandscope">Scope</a> for which you want to delete commands to</td><td>Optional</td></tr><tr><td>2</td><td>Language code</td><td>Optional</td></tr></tbody></table>

{% hint style="info" %}
If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

## Get my commands

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

#### .getMyCommands answer method take arguments:

<table><thead><tr><th data-type="number">Argument</th><th width="331.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td><a href="https://core.telegram.org/bots/api#botcommandscope">Scope</a> you want to get commands</td><td>Optional</td></tr><tr><td>2</td><td>Language code</td><td>Optional</td></tr></tbody></table>

{% hint style="success" %}
Returns **array of** [IBotCommand](https://core.telegram.org/bots/api#botcommand) on success
{% endhint %}

{% hint style="info" %}
If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

## Example

{% code title="app.controller.ts" %}

```typescript
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';
  }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://degreetpro.gitbook.io/nestgram/api-reference/my-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
