How can I create more commands like this one?

Hello team
I have this command


$(eval var str=decodeURIComponent($(urlfetch json$(touser)/stats)); if(str==“Remote Server Returned Code 404”){ ‘:x:Not Found’; }else{ bu=JSON.parse(str) ? JSON.parse(str) : ‘None’; ‘:heavy_check_mark: $(touser) Puzzle Rush Record is 🢂’+bu})🢀 on​:chess_pawn:

which is related to a chess page, this commands sends the best record in a certain part of the game called “puzzle rush”, I would like to know how to create more like this, for other types of games in the same chess page.

I have some other commands related as well which provide the specific rating a player has in different time controls chess games ( in 1 minute chess, 3 minute chess and 10 minute chess) I can send them too if necessary

Hey @Clauwasaki!

I understand that you want to create similar commands based on the API; it returns JSON so it’s quite easy to set up, however, since your request is very broad, the best thing I can offer you is a quick tutorial on how to access data in a JSON.

Hi Emily, I see, I know the specific numbers but I don’t know where to send them afterwards, do I need something to send the data to? like a page or something

I’m not sure I understand your issue, sorry, but hopefully the following example will help you…

Let’s imagine the API responds with the following JSON:

  "firstName": "Edyth",
  "lastName": "Owbridge",
  "pets": [
    "Palm squirrel",
    "African jacana",
  "friends": [

And you want to generate the following sentence:

FIRST_NAME has PETS_AMOUNT pets, one of which is a RANDOM_PET, and their best friend is FRIEND_NUMBER_4.

Then you command will look like this:

$(eval data = $(urlfetch json API_URL); `${data.firstName} has ${data.pets.length} pets, one of which is a ${data.pets[Math.floor(Math.random() * data.pets.length)]}, and their best friend is ${data.friends[3]}.`;)

If you need further help, I’ll need an example of the data output and an example of the sentence you want to generate, like I showed you, as I can’t help blindfolded.

Sorry if it’s broad. I bring this pics to show what I would like to know if it’s possible to make. So in the command I showed in the first comment it sends this info

and I would like to know if it’s possible to get the info let’s say from this part

so my 2 questions are: What info do I need? and What part of the command do I have to change?

I can’t tell you blindfolded, your screenshots help, but I’m still missing the most important part, something similar to this:

You can get it by replacing $(touser) in the URL with your username on, I can’t know it if you don’t tell me your username, and sometimes people don’t want to give that info publicly, that’s why I offered you to show me an example of what the data looks like in JSON instead.

Anyway, when I go to the following URL:

I get the following response:


That’s what I was asking for.

Now, after comparing the data displayed on the website, and the data available on the API endpoint you provided, it looks like it doesn’t include the data for Puzzle Rush → Best 5 min.

And looking at their API documentation I couldn’t find a public endpoint that would have that data.

I see, well then. it can always be made manually and edited as it changes. Thanks a lot for the help!

1 Like

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