getMyCommands method

Future<List<BotCommand>> getMyCommands({
  1. BotCommandScope? scope,
  2. String? languageCode,
})

Use this method to get the current list of the bot's commands for the given scope and user language

Returns Array of BotCommand on success. If commands aren't set, an empty list is returned.

https://core.telegram.org/bots/api#getmycommands

Implementation

Future<List<BotCommand>> getMyCommands(
    {BotCommandScope? scope, String? languageCode}) async {
  var requestUrl = _apiUri('getMyCommands');
  var body = <String, dynamic>{
    'scope': scope == null ? null : jsonEncode(scope),
    'language_code': languageCode,
  };
  return (await HttpClient.httpPost(requestUrl, body: body))
      .map<BotCommand>((botCommand) => BotCommand.fromJson(botCommand))
      .toList();
}