Last active
March 11, 2021 16:17
-
-
Save alxtz/816a7f59c6e04039fc3fa5da00211f70 to your computer and use it in GitHub Desktop.
Nightbot script to fetch HSBG ranks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!commands add -cd=5 !ap | |
$(eval | |
let api = $(urlfetch json https://playhearthstone.com/en-us/api/community/leaderboardsData?region=AP&leaderboardId=BG&seasonId=2); | |
let r = api.leaderboard.rows; | |
let q = "$(1)"; | |
let rest = q.substring(1, q.length); | |
let f = q[0] === '#' ? r[parseInt(rest) - 1] : r.find(u => u.accountid.toUpperCase() === q.toUpperCase()); | |
f === undefined ? `[$(user)]: ${q} not found` : `[$(user)]: ${f.accountid} is currently #${f.rank}, ${f.rating} mmr`; | |
) | |
!commands add -cd=5 !na | |
$(eval | |
let api = $(urlfetch json https://playhearthstone.com/en-us/api/community/leaderboardsData?region=US&leaderboardId=BG&seasonId=2); | |
let r = api.leaderboard.rows; | |
let q = "$(1)"; | |
let rest = q.substring(1, q.length); | |
let f = q[0] === '#' ? r[parseInt(rest) - 1] : r.find(u => u.accountid.toUpperCase() === q.toUpperCase()); | |
f === undefined ? `[$(user)]: ${q} not found` : `[$(user)]: ${f.accountid} is currently #${f.rank}, ${f.rating} mmr`; | |
) | |
!commands add -cd=5 !eu | |
$(eval | |
let api = $(urlfetch json https://playhearthstone.com/en-us/api/community/leaderboardsData?region=EU&leaderboardId=BG&seasonId=2); | |
let r = api.leaderboard.rows; | |
let q = "$(1)"; | |
let rest = q.substring(1, q.length); | |
let f = q[0] === '#' ? r[parseInt(rest) - 1] : r.find(u => u.accountid.toUpperCase() === q.toUpperCase()); | |
f === undefined ? `[$(user)]: ${q} not found` : `[$(user)]: ${f.accountid} is currently #${f.rank}, ${f.rating} mmr`; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment