setGameScore method
Use this method to set the score of the specified user in a game
On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the score is not greater than the user's current score in the chat and force is False.
Implementation
Future<Message> setGameScore(int userId, int score,
{bool? force,
bool? disableEditMessage,
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('setGameScore');
var body = <String, dynamic>{
'user_id': userId,
'score': score,
'force': force,
'disable_edit_message': disableEditMessage,
'chat_id': chatId,
'message_id': messageId,
'inline_message_id': inlineMessageId,
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}