Q: Store output outside the API

Asked Oct 4, 2024·3 replies·Last activity 1 year ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Very new to coding still but I want to know if it's possible to store the value of {{lvl}} or {{elo}} outside of the API. I don't have access to the API being used so I want to know if I can take the values outside of the API and make code within the command.

$(urlfetch https://api.jakobkristensen.com/76561199004437037/Premier Rating: {{rating}} || Faceit level: {{lvl}} || Faceit elo: {{elo}} [[America/North_Dakota/Center]])

3 replies

This is probably possible with a command that is aliased to edit another command with the results from the initial command.

As a simple example:

!commands add !setelo -ul=moderator -a=!commands edit !elo $(eval let d=$(urlfetch json https://api.jakobkristensen.com/76561199004437037); `Rating ${d.rating} - Level: ${d.lvl} - Elo: ${d.elo}`)

and fetch it from !elo

Aaron128l: !elo
Nightbot: Rating 7.241 - Level: 2 - Elo: 521

However this functionally could just be fetched from a single command as is.

Thank you Aaron for responding and helping me. I used the example you gave me here but when you try and use !elo after changing it. This error code pops up

`Nightbot
: Unexpected identifier '$' [<context>:1:429]`

Apologies the forum formatting removed the grave accents (`) in the command. I've edited the previous post with the correct command, you'll need to remove the previous command before creating it.