Customapi help needed


#1

Hiya everyone,

so I am playing and streaming 7 Days to Die a lot. Now I’ve found a nice custom command in the Streamlab Bot Discord. It basically triggers a horde via API command. So I’ve been trying to do the same with Phantombot - but it just does not work. When I enter the URL in the browser it triggers the horde just fine:
http://134.255.235.22:8082/api/executeconsolecommand?adminuser=Test&admintoken=testtest&command=bc-spawn horde %2Fcount%3D40 %2Fgroup%3DZombiesWastelandNight %2Fmin%3D30 %2Fmax%3D60 %2Fplayer%3D76561198011384230

When I try to enter it via API i get an error:
<h1>Bad Request (Invalid request line (version).)</h1>

Now the code in the Streamlab Bot also writes something to a file, but since the URL can be triggered without it and I have no idea how to do that with the Phantombot I left it out.

So basically that’s the original code:
$savetofile(Services\Twitch\Files\spawns.txt","$readapi(http://SERVER:PORT/api/executeconsolecommand?adminuser=ADMIN_NAME&amp;admintoken=ADMIN_PASSWORD&amp;command=bc-spawn%20horde%20%2Fcount%3DENTITY_COUNT%20%2Fgroup%3DENTITY_GROUP%20%2Fmin%3DMIN_RANGE%20%2Fmax%3DMAX_RANGE%20%2Fplayer%3DSTEAM_ID)","This is the $count time zombies get spawned at me in the past $uptime. Thank you, $username, for making my life so interesting!","Not this time, my friend!")

That’s my Phantombotcode:
(customapi http://134.255.235.22:8082/api/executeconsolecommand?adminuser=Test&admintoken=testtest&command=bc-spawn horde %2Fcount%3D40 %2Fgroup%3DZombiesWastelandNight %2Fmin%3D30 %2Fmax%3D60 %2Fplayer%3D76561198011384230) TEST

If someone could help me out that would be great. All I really want is a command to trigger that link.

Thanks in advance


#2

The link seen in your customapi code returns an error in json format:

{"command":"bc-spawn","parameters":"horde /count=40 /group=ZombiesWastelandNight /min=30 /max=60 /player=76561198011384230","result":"Unable to get player position from remote client\r\n"}

On top of this, the response from the api seems to be in json, customapi returns plain text. Luckily, phantombot has a tag for that too, it’s customapijson.

See the examples in the below post for how to use customapijson


#3

Thanks a lot. The error is to be expected since no one is on the server at the moment. Once the person at which the URL is targeted at comes online it works perfectly fine. :slight_smile: That has been tested and works 100%

So my guess is a simple copy paste and just using customapijson wont work? Will have to figure out what to do then. Thanks for the pointers!


#4

You’ll want to target the specific variable you want the bot to print out.

I.E if you wanted it to print the result:

(customapijson http://134.255.235.22:8082/api/executeconsolecommand?adminuser=Test&admintoken=testtest&command=bc-spawn%20horde%20%2Fcount%3D40%20%2Fgroup%3DZombiesWastelandNight%20%2Fmin%3D30%20%2Fmax%3D60%20%2Fplayer%3D76561198011384230 result)


#5

Thanks for the help! :slight_smile: We never figured out how to get it to work since nothing needs to be printed, but it’s a small custom script now - which is probably better since it’s more flexible.

Have a great day / evening. Love the bot!


#6

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