sendGame method

Future<Message> sendGame(
  1. dynamic chat_id,
  2. String game_short_name, {
  3. bool? disable_notification,
  4. int? reply_to_message_id,
  5. bool? allow_sending_without_reply,
  6. InlineKeyboardMarkup? reply_markup,
})
inherited

Use this method to send a game

On success, the sent Message is returned.

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

Implementation

Future<Message> sendGame(dynamic chat_id, String game_short_name,
    {bool? disable_notification,
    int? reply_to_message_id,
    bool? allow_sending_without_reply,
    InlineKeyboardMarkup? reply_markup}) async {
  if (chat_id is! String && chat_id is! int) {
    return Future.error(TelegramException(
        'Attribute \'chat_id\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('sendGame');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'game_short_name': game_short_name,
    'disable_notification': disable_notification,
    'reply_to_message_id': reply_to_message_id,
    'allow_sending_without_reply': allow_sending_without_reply,
    'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}