How to make a command with text for the first person who uses it per stream

Yes, that was already planned, the whole thing will be automated, don’t worry. :wink:


We’ll use the Quote API, get your tokens by following the Manual Installation link.
Refer to the following to identify your PUBLIC_TOKEN and PRIVATE_TOKEN:

$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&data=$(querystring))

Copy them and store them somewhere safe, never share your PRIVATE_TOKEN, anyone could then manage your list, that’s why the code I’ll write won’t contain command calls to add the new commands through the chat, add the new commands through the dashboard.


The command will be split in two parts, the second half being the alias of the first one:

  • Command: !first
    Message:

    $(eval const l = '$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=-1&no_id=1)'.split(' | '); const s = '$(twitch $(channel) "{{uptimeAt}}")'; const u = '$(user)'; !l[0].includes(s) ? `PRIVATE_TOKEN&data=${encodeURI(s + ' | ' + u)}` : l[1].includes(u) ? `Yes ${u}, you were first today!` : `Sorry ${u}, you were not first today, ${l[1]} was!`;)
    

    Alias: _first

  • Command: _first
    Message:

    $(eval const q = decodeURI('$(query)'); const a = '$(urlfetch https://twitch.center/customapi/addquote?token=$(query))'; !q.includes('PRIVATE_TOKEN') ? q : a.includes('Successfully added') ? `Congratulations ${q.split(' | ')[1]}, you are first!` : 'There was an error, try again later';)
    

All you have to do now is to replace the PUBLIC_TOKEN (1) and PRIVATE_TOKEN (2) fields, and add the commands to your instance of Nightbot through the dashboard.

1 Like