Utilizing Custom Quote API for Community Writing

Hey guys,

I’m looking to utilize the custom quote API in order to create a method of community writing.

In this situation, someone would use a !addword command to start a sentence, for instance, “the”, then someone else could add to that quote like “!addword cat” making the current quote now be “the cat” and continue from there.

With my basic level understanding of Javscript, I’m having a hard time getting the API to accept a variable stated in the eval command, within the URL fetch.

Here is my current attempt:
$(eval var y; var x = “$(urlfetch https://twitch.center/customapi/quote?token=TOKEN&no_id=1)”; y = x + ‘$(querystring)’;
$(urlfetch https://twitch.center/customapi/editquote?token=TOKEN&data=y):wink:


Inner Nightbot variables always resolve before the outer variables. The $(urlfetch)'s do not “know” that they are nested within an $(eval); thus with this command setup you are literally sending the letter “y” as the data parameter to the quote API.

This command setup should accomplish what you need. Replace PUBLIC_TOKEN with your public token (8 characters long) and PRIVATE_TOKEN with your private token (16 characters long).

!addcom -cd=5 !addword $(eval z=`$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=~W~$(querystring))`;a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`~W~`).filter(b=>b!=``).join(` `).slice(0,400);a&&a!=`There are no quotes added`?a:`There are no phrases added yet...`)

I’ve also set up a command !resetword (mod-only) to clear the phrases. Replace PRIVATE_TOKEN with your private token.

!addcom -ul=mod !resetword $(eval `$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`==`All entries have been deleted`?`$(user) has reset the word!`:`Try again...`)

You are honestly so amazing! It works perfectly and you are my Savior!

By reading your code I have learned a great deal about how the code is interpreted as well, and should help me in a few other things.

Thanks you!

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