NightDev Community Forums

Command with response

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

Hey @PandaClub!

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 @EmilyPerrimon.

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

Oooh, so api.pstatus.dev isn’t a real API, gotcha, that put me on a wrong path…

I’ve wrote a short guide on api.tracker.gg: Warzone custom API command - #11 by EmilyPerrimon

However, I think this part specifically will interest you more: Warzone custom API command - #13 by EmilyPerrimon
It’s not a perfect command as I didn’t include error handling, but it’s not difficult to add.