Queue command nightbot

Hi!
Is it possible to make a custom command for nightbot so you can list queues?
Like if you for example write !joinqueue it saves your name in a list, so you can see who’s the next person who can join viewergames.
Like this:
test1: !joinqueue
test2: !joinqueue
test3: !joinqueue

host: !viewqueue
Nightbot:

  1. test1
  2. test2:
  3. test3

so basicly the first person who wrote !joinqueue is in the top of the list

Thx for help!

Update: I made new queue commands that are more versatile and include a leave feature. Here is the website that generates the commands: https://vxrl.xyz/commands/queue

Go to https://twitch.center/customapi/quote/generate. You will see three lines. After token= on the first line, you will see your first token. After token= on the second and third lines, you will see your second token. Use these to replace FIRSTTOKEN and SECONDTOKEN before you add the following commands.

COMMANDS FROM THE ORIGINAL REPLY

!commands add !joinqueue -a=!joinqueueadder $(eval queueString = `$(urlfetch http://twitch.center/customapi/quote/list?token=FIRSTTOKEN)`; userExists = false; regex = /\d+\. (.*?) /g; while ((match = regex.exec(queueString)) !== null){if (match[1] === `$(user)`){userExists = true}} if (userExists) {"="} else {"=" + encodeURIComponent(`$(user) `)})

!commands add !joinqueueadder $(eval `$(urlfetch http://twitch.center/customapi/addquote?token=SECONDTOKEN&data$(query))`.includes("Successfully added entry") ? `$(user) was added to the viewer game queue` : `$(user) is already in the viewer game queue`)

!commands add !viewqueue $(eval (queueString = `$(urlfetch http://twitch.center/customapi/quote/list?token=FIRSTTOKEN)`) === "There are no quotes added" ? "The viewer game queue is empty" : queueString)

!commands add !popqueue -ul=moderator $(eval (removedViewer = `$(urlfetch http://twitch.center/customapi/delquote?token=SECONDTOKEN&data=1)`).includes("Successfully deleted entry") ? (removedViewer.substr(removedViewer.indexOf(":") + 1) + " was removed from the viewer game queue") : "The viewer game queue is already empty")

!commands add !clearqueue -ul=moderator $(eval if (`$(urlfetch http://twitch.center/customapi/quote/list?token=FIRSTTOKEN)` === "There are no quotes added"){"The viewer game queue is already empty"} else {`$(urlfetch http://twitch.center/customapi/delquote?token=SECONDTOKEN&clear=1)`; "The viewer game queue has been cleared"})
2 Likes

Thank you so much for the reply!
I did exactly what u said. Replaced FIRSTTOOKEN and SECONDTOKEN with the tokens from the generate link, and entered it to the twitch chat. After the numbers and letters there are som more: “&data=$(querystring))”. Should I replace these aswell? Or are the tokens only the first numbers and letters before “&data”?
I get this for answer by Nightbot:
I first wrote !joinqueue ; "AlqeeNo was added to the viewer game queue"
So !joinqueue seems fine, but when I write !viewqueue; “Right-hand side of ‘instanceof’ is not an object === “There are no quotes added” ? “The viewer game queue is empty” : queueString)”.
I dont know what im doing wrong, but you may know? :smiley:
-AlqeeNo

And are there any specific order I need to write these commands, or do I need to write something after the command? For example: “!joinqueue nickname

The tokens are after token= and before &data=

Make sure that you are copying the commands exactly, and only replacing FIRSTTOKEN and SECONDTOKEN. I just did this and can verify that the commands work. Also let me know if you want me to make a !leavequeue command that allows the viewers to remove themselves.

I did replace tokens in the right way now, and I dont get that long error anymore, but I get “Right-hand side of ‘instanceof’ is not an object” when I write !viewqueue :frowning:

I promise you that the command works. Make sure you are writing it correctly.

Seems like that message doesnt appear anymore for some reason. hmm weird! It works now :smiley: but what is !joinqueueadder (for moderators only) for?

Anyways, thank you so much for the help!

Nobody should be manually activating !joinqueueadder. It is a helper command that !joinqueue automatically uses. It is necessary because there is no other way to pass information from the $(eval)'s JavaScript to a Nightbot variable.

2 Likes

Tested it on a live stream with 30 viewers now, where im mod. Only I can write !joinqueue and get added in the list (and response from nightbot). When the other viewers write !joinqueue, nightbot doesnt respond. I have it on “userlevel: everyone” ofcourse. How come?

Maybe the !joinqueueadder alias only works if a mod writes the !joinqueue-command?

Alright so I found out that !joinqueueadder had to be userlevel: everyone, then everyone can write !joinqueue and be added to the list :slight_smile: thats awesome!
One more thing. Sry for bothering you so much, but is there any way to make a command !queuenext? So the nr 1 person in the list gets removed and nr. 2 becomes nr. 1?

I forgot that this is how that works. You can make !joinqueueadder’s userlevel “everyone”, but then people can add arbitrary things to the queue. I’ll have to think about a better solution.

That’s what !popqueue does

Got this when I wrote !popqueue:
"$(eval (removedViewer = $(urlfetch http://twitch.center/customapi/delquote?token=TOKEN&data=1)).includes(“Successfully deleted entry”) ? ( removedViewer.substr(removedViewer.indexOf( “:”) + 1) + " was removed from the viewer game queue") : “The viewer game queue is already empty”

Is it bad when the token gets public for all in the chat? :stuck_out_tongue:

It looks like you didn’t copy the last right parenthesis. And if your token is posted publicly, it means that anyone can edit your list.

Awesome! Popqueue works now aswell. Dno if the public !joinqueadder is a real problem tho :smiley: It could be if ppl starts to abuse the command.

Is it possible to make a command so I can write !joinqueue nickname", so I can add people in the list without them have to write the command themselves?

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