getGameHighScores method
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.
Implementation
Future<List<GameHighScore>> getGameHighScores(int userId,
{dynamic chatId, int? messageId, String? inlineMessageId}) async {
if (inlineMessageId == null && (chatId == null || messageId == null)) {
return Future.error(TelegramException(
'Require either \'chatId\' and \'messageId\', or \'inlineMessageId\''));
}
if (chatId != null && (chatId is! String && chatId is! int)) {
return Future.error(TelegramException(
'Attribute \'chatId\' can only be either type of String or int'));
}
var requestUrl = _apiUri('getGameHighScores');
var body = <String, dynamic>{
'user_id': userId,
'chat_id': chatId,
'message_id': messageId,
'inline_message_id': inlineMessageId,
};
return (await HttpClient.httpPost(requestUrl, body: body))
.map<GameHighScore>(
(gameHighScore) => GameHighScore.fromJson(gameHighScore))
.toList();
}