Skip to content

Instantly share code, notes, and snippets.

@alxtz
Last active March 11, 2021 16:17
Show Gist options
  • Save alxtz/816a7f59c6e04039fc3fa5da00211f70 to your computer and use it in GitHub Desktop.
Save alxtz/816a7f59c6e04039fc3fa5da00211f70 to your computer and use it in GitHub Desktop.
Nightbot script to fetch HSBG ranks
!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