Class Game

Hierarchy (view full)

Constructors

Properties

animation: Animation

Animation that will be displayed in the game message in chats. Upload via BotFather

description: string

Description of the game

entities: MessageEntities

Special entities that appear in text, such as usernames, URLs, bot commands, etc

photo: Photo[]

Photo that will be displayed in the game message in chats

text: string

Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters

title: string

Title of the game

Accessors

Methods

  • Protected

    Patches the current instance with new data

    Parameters

    • data: Record<string, any>

      The data to patch the instance with

    Returns Record<string, any>

    The patched data

  • Protected

    Updates the current instance with new data and returns a clone of the updated instance

    Parameters

    • data: Record<string, any>

      The data to update the instance with

    Returns Base

    A clone of the updated instance

  • 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.

    Parameters

    • userId: string | number

      Target user id

    • Optionaloptions: Omit<{
          chatId?: string | number;
          inlineMessageId?: string;
          messageId?: string | number;
          userId: string | number;
      }, "userId">

      out parameters

    Returns Promise<GameHighScore[]>

    Returns an Array of GameHighScore objects. This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.

  • 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.

    Parameters

    • userId: string | number

      User identifier

    • score: number

      New score, must be non-negative

    • Optionaloptions: Omit<{
          chatId?: string | number;
          disableEditMessage?: boolean;
          force?: boolean;
          inlineMessageId?: string;
          messageId?: string | number;
          score: number;
          userId: string | number;
      }, "userId" | "score">

      out parameters

    Returns Promise<boolean | Message & {
        editedTimestamp: number;
        game: Game;
    }>

    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.