[CustomAPI] Quote system

Hey @chloelunn9!

Yes you can! I assume you’re using Random Requests Command so I’ll go from there and update it to check if they already reached the maximum number of requests before adding or declining theirs.

So instead of simply having:

$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(user) - $(querystring))

It’ll be something like this:
!request:

$(eval d=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.replace(/\d+\./g,` -`).split(` - `); t=0; d.forEach(e=>e==`$(user)`?t++:t); t>10?`max`:`PRIVATE_TOKEN&data=$(user) - $(querystring)`;)

And now !request will have an alias:
_request:

$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`; q=`$(query)`; q==`max`?`You reached the maximum amount of requests, please be patient.`:a;)

Notes:
• Right now the limit is at 10 requests, you can set it higher or lower by adjusting the number in the t>10 test in the first command.
• You can also change the message they get when they reached the maximum amount of requests in the second command.

1 Like