API Command Help

Hello. I am attempting to create a command that will return a players first_name and last_name from an API response. As a bonus I would also like to add a random number between 1-3000 to the end of query string. I’ve had no success using the nightbox syntax. Thanks in advance.

API url(works with no token, using id 3000 for example)
https://www.balldontlie.io/api/v1/players/3000

Command syntax I have:
not sure how to only pull first_name and last_name properties

$(user) wants to know which college, $(eval const api = $(urlfetch json https://www.balldontlie.io/api/v1/players/3000)), went to

Something as simple as

!commands add !ball $(user) wants to know which college, $(eval const p=$(urlfetch json https://www.balldontlie.io/api/v1/players/$(eval ~~(Math.random() * 3000) + 1)); `${p.first_name} ${p.last_name}`) went to.

should work.

1 Like

Brilliant! This worked. Thanks :+1:

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