Command with $(querystring) verification & $(urlfetch)

Hi guys! So I have this command string that works like a magic 8 ball. The command must be followed by a question (doesn’t even need to end in a question mark; there just has to be text).

This is what I currently have:

$(eval responses=[Yes, No, Maybe, Try again later]; $(querystring).trim() == `` ? Please ask a question first. : responses[Math.floor(Math.random()*responses.length)])

I now have a website that generates a random response - literally just a url that says “yes” and then when refreshed will randomly select another response like “no” or “maybe”. How do I incorporate $(urlfetch) into this?

I’ve tried just doing the below, but it doesn’t work right:
$(eval responses=[$(urlfetch https://api.scorpstuff.com/catfacts.php); $(querystring).trim() == `` ? Please ask a question first. : responses[Math.floor(Math.random()*responses.length)])

I’ve also tried doing other variants too like the below but while the url works, the query verification doesn’t:
$(urlfetch https://api.scorpstuff.com/catfacts.php); $(querystring).trim() == `` ? Please ask a question first.`

Any tips would be appreciated!

Hiya, so the catfacts.php will already choose a random answer, so you won’t have to select a random answer in your js code. Something like this should work:

$(eval '$(querystring)'.trim() == '' ? 'Please ask a question first.' : `$(urlfetch https://api.scorpstuff.com/catfacts.php)`)

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