TopBoardLib

TopBoardLib is a lib designed for managing a leader board in a chatbot. It provides functionality for adding, updating, retrieving, and resetting user scores, as well as managing multiple leader boards.

Methods

addScore(params)

Adds or updates a user's score on the leader board.

Parameters:

params: An object containing:

  • value (Number): The score value to be added.

  • boardName (String, optional): The name of the leader board, default is "default".

  • maxCount (Number, optional): The maximum number of entries on the board, default is 10, max is 25

  • fields (Object, optional): Additional fields for the user's entry.

getBoard(boardName)

Retrieves a leader board by its name.

Parameters:

  • boardName (String, optional): The name of the leader board, default is "default".

Returns:

  • An array of entries on the leader board.

  • each record it is:

resetBoard(boardName)

Resets the leader board, removing all entries.

Parameters:

  • boardName (String, optional): The name of the leader board, default is "default".

Usage Examples

in /gameOver command:

in /top command:

You also can pass another user data to TopBoardLib.addScore method

Other methods

getUserPropName(boardName) - this method return prop name for storing user's score. You can use it to prevent duplicate information. For example, if you have a user balance, then you can store it with this property name

Last updated

Was this helpful?