Dynamic rank command

Hi there,

I was trying to create a dynamic !rank command that uses the game title on stream to call the relevant API to display my rank in each game. I got it working pretty well, but I’m limited in how long the command can be, so can’t add every game that I play.

The command that I’m currently using is:

*$(eval var r = false; if(’$(twitch dobton_ “{{game}}”)’ == “Rocket League”) r = “$(urlfetch https://bit.ly/link)”; *

else if(’$(twitch dobton_ “{{game}}”)’ == “VALORANT”) r = “$(urlfetch https://bit.ly/link)”;

*else if(’$(twitch dobton_ “{{game}}”)’ == “League of Legends”) r = “$(leagueoflegends dobton euw)”; *

else if(’$(twitch dobton_ “{{game}}”)’ == “Teamfight Tactics”) r = “$(leagueoflegends dobton euw ranked_tft)”; if® 'Current rank: ’ + r + ‘.’; else ‘At least Plat.’; )

I’ve had to use bitly to shorten the URLs for the urlfetches to fit (removed the actual links).

I’m just wondering if there is a better way of doing this? I originally looked at creating a command that would call a game specific rank command based on the game title, but from what I’ve read this isn’t possible. Would I have to create a script or API to achieve the desired result?

Here’s how I would shorten it if I were in your shoes

$(eval 
q=`$(twitch dobton_ "{{game}}")`;
r=`false`;
s=[`$(urlfetch https://bit.ly/link)`,
`$(urlfetch https://bit.ly/link)`,
`$(urlfetch https://bit.ly/link)`,
`...`];
$(urlfetch json https://pastebin.com/raw/xxxxxx))

Then I’d have the pastebin look like this

if(q==`game1`){r=s[0]};
if(q==`game2`){r=s[1]};
if(q==`game3`){r=s[2]};
if(q==`gameX`){r=s[X-1]};
r!=`false`?`Current rank: ${r}.`:
`At least Plat.`

Note: if needed you can shorten the pastebin link

Thanks for the help. That should work a treat :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.