getGameHighScores method

Future<List<GameHighScore>> getGameHighScores(
  1. int user_id, {
  2. dynamic chat_id,
  3. int? message_id,
  4. String? inline_message_id,
})
inherited

Use this method to get data for high score tables

Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.

This method will currently return scores for the target user, plus two of his closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change.

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

Implementation

Future<List<GameHighScore>> getGameHighScores(int user_id,
    {dynamic chat_id, int? message_id, String? inline_message_id}) async {
  if (inline_message_id == null && (chat_id == null || message_id == null)) {
    return Future.error(TelegramException(
        'Require either \'chat_id\' and \'message_id\', or \'inline_message_id\''));
  }
  if (chat_id != null && (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('getGameHighScores');
  var body = <String, dynamic>{
    'user_id': user_id,
    'chat_id': chat_id,
    'message_id': message_id,
    'inline_message_id': inline_message_id,
  };
  return (await HttpClient.httpPost(requestUrl, body: body))
      .map<GameHighScore>(
          (gameHighScore) => GameHighScore.fromJson(gameHighScore))
      .toList();
}