I am trying to write a command that adds an item onto a list of items. I have tried multiple methods of varying complexity and have always hit some sort of snag with the command structure, is there an easy way to do this or at least does someone have a way that has made it work? I am trying to avoid just copy pasting the current list into an editcom every time.
I would like to make a command that adds an item onto a list of items
7 replies
Hey @Tangy Deer!
You can use ehsankia's quote system for this.
That is a very good system, however I would like to be able to play the list in chat instead of it going out to another website, what I want is less of a behind the scenes list to pull from, and more of a command that displays the total list, and a command that can add on to the list without overwriting it every time. If this is possible through that quote system and I misunderstood I'm sorry I'm pretty new to nightbot commands.
Yeah, so here's how it'd work:
Moderators' command:
Add it from the dashboard, make sure to set the userlevel as Moderator. Don’t use the chat as anyone could monitor it and copy the PRIVATE_TOKEN, they could then edit your data.
$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring),)
Everyone's command:
!addcom !list $(eval u=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`,`);u.pop();`List of items: ${u.join(`, `)}. Consult the full list here: https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN`})
Or if you get too many items that it reaches more than 400 characters, I can recommend picking items at random from the list, in this example you'll get 10 items, 9 at random, the 10th being the last entered item. If you want more items, feel free to replace the 9 in the for loop with another number:
!addcom !list $(eval u=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.split(`,`);u.pop();t=u.length;s=[];l=u.pop();for(i=0;i<9;i++){s.push(u.splice(Math.floor(Math.random()*u.length),1));}`Here's a small selection of the items in the list: ${s.join(`, `)}, and ${l}. Total: ${t} items. Consult the full list here: https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN`})
You'll get your TOKENS by clicking on the second link in the quote system API post, in the Manual Installation section, use these in the commands I wrote. To know where to look for your PUBLIC_TOKEN and PRIVATE_TOKEN, look at the field bellow:
$(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))
Keep your PRIVATE_TOKEN secret, don’t share it anywhere. Add the following commands from the dashboard. Don’t use the chat as anyone could monitor it and copy the token, they could then edit your data.
Didn't find your answer? The community is on Discord.
Ask on Discord