# Handling commands

## Handle command

To handle a command, you can use `@OnCommand` decorator

{% hint style="info" %}
Optional. `@OnCommand` takes command you want to listen to as argument
{% endhint %}

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

{% hint style="info" %}
You can read more about property decorators [here](https://degreetpro.gitbook.io/nestgram/handling-updates/other-arguments-in-handler)
{% endhint %}

## Example

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

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

{% endcode %}
