getGameHighScores method

Future<List<GameHighScore>> getGameHighScores(
  1. int userId, {
  2. ID? chatId,
  3. int? messageId,
  4. String? inlineMessageId,
})

Gets data for high score tables.

Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.

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

Implementation

Future<List<GameHighScore>> getGameHighScores(
  int userId, {
  ID? chatId,
  int? messageId,
  String? inlineMessageId,
}) async {
  final params = <String, dynamic>{
    'user_id': userId,
    'chat_id': ?chatId,
    'message_id': ?messageId,
    'inline_message_id': ?inlineMessageId,
  };

  final payload = Payload(params);
  final response = await _makeRequest<List<dynamic>>(
    APIMethod.getGameHighScores.name,
    payload,
  );

  return response.map((json) => GameHighScore.fromJson(json)).toList();
}