setGameScore method
Future<Message>
setGameScore(
- int user_id,
- int score, {
- bool? force,
- bool? disable_edit_message,
- dynamic chat_id,
- int? message_id,
- String? inline_message_id,
inherited
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 user_id, int score,
{bool? force,
bool? disable_edit_message,
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('setGameScore');
var body = <String, dynamic>{
'user_id': user_id,
'score': score,
'force': force,
'disable_edit_message': disable_edit_message,
'chat_id': chat_id,
'message_id': message_id,
'inline_message_id': inline_message_id,
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}