kyroskoh

Valorant API for Nightbot

May 4th, 2021 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. !addcom !valorank $(eval response = `$(urlfetch json https://api.henrikdev.xyz/valorant/v1/mmr/ap/Kiki/7590)`; try { json = JSON.parse(response); currenttierpatched = json.data.currenttierpatched; currenttierpatched == null ? "None" : currenttierpatched; } catch(e) { `${e}: ${response}`.substr(0, 400)})
  2.  
  3. Note: the URL API needs to be formatted like this: https://api.henrikdev.xyz/valorant/v1/mmr/[region]/[username]/[tagline]
  4.  
  5. Above example of https://api.henrikdev.xyz/valorant/v1/mmr/ap/Kiki/7590 with breakdown as follows:
  6.  
  7. [Region]
  8. ap = asia pacific
  9. na = north america
  10. eu = europe
  11. kr = korea
  12.  
  13. If your IGN is Kiki#7590: your [username] is Kiki, your [tagline] is 7590.
  14.  
  15. ^ This command will display as: Diamond 2.
  16.  
  17. The below is the API response:{ "status": "200", "data": { "currenttier": 19, "currenttierpatched": "Diamond 2", "ranking_in_tier": 56, "mmr_change_to_last_game": -21, "elo": 1656 } }
  18.  
  19. You can add more command for currenttier, ranking_in_tier, mmr_change_to_last_game and elo, just replace the variable respectively such as:
  20.  
  21. !addcom !valoelo $(eval response = `$(urlfetch json https://api.henrikdev.xyz/valorant/v1/mmr/ap/Kiki/7590)`; try { json = JSON.parse(response); elo = json.data.elo; elo == null ? "None" : elo; } catch(e) { `${e}: ${response}`.substr(0, 400)})
  22.  
  23. Which will return the result as: 1656.
  24.  
  25. ---
  26.  
  27. If you want to display like:
  28.  
  29. [Diamond 2]: 1656.
  30.  
  31. It will need to be like this:
  32.  
  33. $(eval response = `$(urlfetch json https://api.henrikdev.xyz/valorant/v1/mmr/ap/Kiki/7590)`; try { json = JSON.parse(response); currenttierpatched = json.data.currenttierpatched; elo = json.data.elo; currenttierpatched && elo == null ? "None" : "[" + currenttierpatched + "]: " + elo + "."; } catch(e){`${e}: ${response}`.substr(0, 400)})
  34.  
  35. ---
  36.  
  37. Main (Kiki#7590 - ap region): [Diamond 3] - Ranking #29 / Elo: 1729.
  38.  
  39. Main (Kiki#7590 - ap region): $(eval response = `$(urlfetch json https://api.henrikdev.xyz/valorant/v1/mmr/ap/Kiki/7590)`; try { json = JSON.parse(response); currenttierpatched = json.data.currenttierpatched; ranking_in_tier = json.data.ranking_in_tier; elo = json.data.elo; currenttierpatched && ranking_in_tier && elo == null ? "None" : "[" + currenttierpatched + "] - Ranking #" + ranking_in_tier + " / Elo: " + elo + "."; } catch(e){`${e}: ${response}`.substr(0, 400)})
Add Comment
Please, Sign In to add comment