$getLeaderboardPosition
The function $getLeaderboardPosition allows retrieving the position (rank) of the current user in the active leaderboard. This function only makes sense in the context of iterating through a leaderboard — that is, after calling $globalUserLeaderboard, $serverLeaderboard or $userLeaderboard and while iterating through their results.
Syntax
$getLeaderboardPosition
How It Works
When you use a leaderboard, the system iterates through each entry one by one. During this iteration, $getLeaderboardPosition exposes the current rank (1 for the first, 2 for the second, etc.).
The returned value corresponds to the internal variable ((leaderboard.position)) which is resolved at runtime by the dedicated leaderboard action.
Use Cases
Typically, you use $getLeaderboardPosition with $textSplit to split the leaderboard result line by line, then display the positions:
- Display a formatted ranking with ranks
- Compare the current user’s position with others
- Build custom messages based on rank (podium, top 10, etc.)
Important
$getLeaderboardPositionreturns nothing outside the context of an active leaderboard.- The function takes no parameters.
- It is typically paired with
$getLeaderboardValuewhich gives the value associated with that position. - The leaderboard itself is generated by a dedicated action at code execution time.
See Also
$getLeaderboardValue— Get the value associated with the current position$globalUserLeaderboard— Global user leaderboard$serverLeaderboard— Server-level leaderboard$userLeaderboard— Personal leaderboard$textSplit— Split the result of a leaderboard
Examples
Leaderboard Rank
$title[Leaderboard Rank 🏆]
$description[<@$authorID>, your current rank is **#$getLeaderboardPosition**!]
$color[#FEE75C]
$sendMessage[]