How to add json custom api command to Nightbot?


So I was trying to figure out how to make a !song command which returns the name of a song from Spotify when the song is from a user’s Local Files.

I managed to figure out the command that works with Phantombot, but I’d like to make it work with Nightbot, but not sure what I need to change.

The command that works with Phantombot is along the lines of:

I tried using $(customapi…), but the response is “[Response must be less than 400 characters]”

Many thanks for any help in advance!

1 Like

Here is a simple command without error handling:

$(eval ($(urlfetch json

Here is a more complicated command that handles errors:

$(eval r=decodeURIComponent("$(querystring $(urlfetch json");try{JSON.parse(r)}catch(e){`Failed to parse Spotify API response: ${e.message}: ${r}`.slice(0,400)})

Many thanks, it’s working beautifully! :slight_smile:

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