Command with response

Asked Apr 30, 2021·3 replies·Last activity 5 years 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.

Hi,

Is it possible to do a command and replace the string with whatever the message after command is in a URL?

Example: !pstatus <user#0000> will replace a string in the URL with the <user#> part making it https://api.pstatus.dev/api/usr/<user#0000> which is fetched from after the !command trigger? I'm trying $(touser) but it sometimes returns Unexpected identifier

3 replies

Hey @Quirky Pufferfish!

Do you have the API documentation around?
We can't help if we don't know what the API is for, and what it's requiring to work.

Hi @member

It's for tracker.gg COD they don't have an API doc around. I've worked out how to do it for myself i.e when I do "pstats it defaults to my Twitch name as that's the same as my ActID.

The full command is:

$(eval s=$(urlfetch json https://api.tracker.gg/api/v2/warzone/standard/profile/atvi/**username#00000**).data.segments[0].stats; r=s.kdRatio.value; k=s.kills.value; d=s.deaths.value; w=s.wins.value; Wins: ${w} | Kills: ${k} | Deaths: ${d} | Kills/Deaths Ratio: ${r})

The part in bold [username#00000] i'm trying to replace with what the user enters after the command. So if I was to do !pstats demo#99999 it'd replace the username#0000 with the demo#99999 etc and if they only enter pstats it returns a message like Incorrect format. missing user#ID or something.

Cheers