Games

setGameScore()

Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

parameters

parametertyperequireddescription
user_idnumberrequiredUser identifier
scorenumberrequiredNew score, must be non-negative
forcebooleanoptionalPass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.
disable_edit_messagebooleanoptionalPass True if the game message should not be automatically edited to include the current scoreboard
chat_idnumberoptionalRequired if inline_message_id is not specified. Unique identifier for the target chat.
message_idnumberoptionalRequired if inline_message_id is not specified. Identifier of the sent message.
inline_message_idstringoptionalRequired if chat_id and message_id are not specified. Identifier of the inline message.

returns

Message | boolean

usage in yaebal

not (yet) hard-typed on Api — call it through the generic .call<T>() escape hatch documented in @yaebal/types.

bot.ts
import type { Message, SetGameScoreParams } from "@yaebal/types";

await bot.api.call<Message | boolean>("setGameScore", {
  user_id: 123456789,
  score: 1,
} satisfies SetGameScoreParams);

context shortcut

also available as ctx.setGameScore() on 16 context types — see @yaebal/contexts.

context shortcut
/** Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Returns an error, if the new score is not greater than the user's current score in the chat and *force* is *False*. */
ctx.setGameScore(params: Omit<SetGameScoreParams, "user_id" | "chat_id" | "message_id">)