hello! i am trying to make a request to an api based on a given input from a user & also include a default response if no input is given. here is how far i was able to get, it only returns the json object for testing/simplicity for now but i do have an actual formatted response for once this is functional.
$(eval r=(`$(1)` == `null`) ? $(urlfetch json https://mcsrranked.com/api/users/nealxm) : $(urlfetch json https://mcsrranked.com/api/users/$(1)); r)
when run with an input (!command feinberg) i get an appropriate response [object Object] . my trouble comes when i run this with no input (!command) i get the response Unexpected identifier.
i started troubleshooting by trying to simplify command by removing the falsy section of the ternary:
$(eval r=(`$(1)` == `null`) ? $(urlfetch json https://mcsrranked.com/api/users/nealxm) : "some input given"; r)
and this gave expected responses. running !command returns [object Object] and running !command feinberg returns some input given. both to be expected.
this result was confusing since i don't understand what would cause the truthy section of the ternary to only work sometimes. is anyone able to help me see what i am missing here? thanks for your time