Names into a list style command

Asked Nov 1, 2022·4 replies·Last activity 3 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

im wondering if theres a way to do something along the lines of !addname Fred to a command of !names and itll then name all the names added via the !addname command - not sure if this would be a pastebin type thing? itll look like the below if possible:

!names Fred, Bob, John

!addname Frank

!names Fred, Bob, John, Frank

4 replies

Hey @Zesty Llama!

I've personally repurposed the quote API for something very similar.

Hi @Polar Cat would this be just renaming the command triggers to what you would want them to be? If I’ve already got the quote api utilised on a different command would I still be able to use it?

How would this then name the commands in twitch chat when doing the main command - would it be via a pastebin/web source or plain text in chat?

Zesty Llama said:
I’ve already got the quote api utilised on a different command would I still be able to use it?

Yes, you can have two quotes API on one instance of Nightbot, you must use a second set of tokens however, and don't use the automatic install because it'll erase the existing quote commands, instead there's a link that'll generate tokens for you in the manual installation part of the post.

Zesty Llama said:
Would this be just renaming the command triggers to what you would want them to be?

Yes, just give the commands the names you'd like.

Zesty Llama said:
How would this then name the commands in twitch chat when doing the main command - would it be via a pastebin/web source or plain text in chat?

I'd recommend doing both, because the list of names will get longer and longer, and Twitch chat is limited to 500 characters, to go around that, I've used the following command:

$(eval u = `$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.split(/\d+\.\s/); u.shift(); t = u.length; s = []; l = u.pop(); i = 0; while(u.length > 0 && i < 9) {s.push(u.splice(Math.floor(Math.random() * u.length), 1)); i += 1; } `Here's a small selection of names: ${s.join(', ')}, and ${l}. Total: ${t} names. Consult the full list here: https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN`)

This will spit out 10 names maximum: 9 random (possibly less if there's not enough names in the list), and the latest one added, as well as a link to consult the full list.
Replace the two instances of PUBLIC_TOKEN with yours: the one that is 8 characters long.

In case you need to know where to look for your PUBLIC_TOKEN and PRIVATE_TOKEN, look at the field bellow once you generated your tokens:

$(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))