Nightbot giving streamelements points to a user when streamelements says a specific phrase

Asked Aug 18, 2023·6 replies·Last activity 2 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.

I have a very complex system that I want to set up. I have a !slots command (through streamelements) that I want nightbot to be able to recognize if the user wins, and it automatically trigger a command to !givepoints (winning user) 500. The streamelements output of the !slots command looks like this when won: (user), you played slots and got | | | | The winning emote is

The first three emotes are with the ${random.emote} variable in streamelements. I would like nightbot to be able to recognize if they are matching and if they are, activate a !givepoints to give the winning user 500 points.

I understand it's very complicated and likely not possible due to it crossing between the two bots and using a recognition feature on nightbot that I'm not sure exists. But I am open to other methods that I could do this with.
I can try to redo the !slots command through nightbot, which I had previously with this:
$(user), you played slots and got $(eval a=$(urlfetch json [link)](link)%60).split(,);a[Math.floor(Math.random()*(a.length-1))]) | $(eval a=$(urlfetch json [link)](link)%60).split(,);a[Math.floor(Math.random()*(a.length-1))]) | $(eval a=$(urlfetch json [link)](link)%60).split(,);a[Math.floor(Math.random()*(a.length-1))])
But, this would often result in an "Error Connecting To WebEval Service" that I could not figure out how to fix.
If it is easier/better, I could I could do it entirely through Nightbot, meaning it would be more like a slots game as all three emotes would need to match for the user to win (instead of just matching 1) but I would need to know how to fix the "Error Connecting To WebEval Service"

1.png1.png1.png

6 replies

unfortunately, much to my dismay, they changed nightbot to completely ignore streamelements... it broke several of my commands...
but as for that other version u have there, if u'd mash them together, so is just one $(eval) with just one $(urlfetch) and randomly pick from the pool multiple times(the same math.floor yada yada yada), it would cause less of a delay and likely reduce the webeval error frequency... i can't promise a full fix, but it'd be less demanding on the service and less chance for a timeout (often what the webeval error means)

thank you, I was able to fix the “Error Connecting To WebEval Service” with some research so I am now able to have the command be nightbot only. is there a possible way to have nightbot detect when theres a winner to automatically trigger a command to give points either through a detection system I am not aware of, or it detecting " (emote) | (emote) | (emote) as a command input. I can have it moved to the beginning so nightbot sees it as a command if I make it as one, but it does have spaces so I don't know if thats possible. if it helps there are only 4 different emotes, so if theres a way to make (emote) | (emote) | (emote) a command name I would only need it 4 times/4 different commands. the way I currently have it is when a person wins, I have to manually do !winner @ (person that won) which then triggers nightbot to !addpoints $(touser) 10

is there a way to possible add (emote) | (emote) | (emote) as a command name or have a different way of detecting it?

nightbot will not respond to itself... but u r able to alias to a second command and accept that command's output as input to the second

$(user), you played slots and got $(eval a=$(urlfetch json [link)](link)%60).split(,);a[Math.floor(Math.random()(a.length-1))]) | $(eval a=$(urlfetch json [link)](link)%60).split(,);a[Math.floor(Math.random()(a.length-1))]) | $(eval a=$(urlfetch json [link)](link)%60).split(,);a[Math.floor(Math.random()*(a.length-1))])

yeah, the singular version i was talking about could go something like this...

js
$(user), you played slots and got $(eval a=`$(urlfetch whateverLink)`.split(`,`);a[Math.floor(Math.random()*(a.length-1))]+` | `+a[Math.floor(Math.random()*(a.length-1))]+` | `+a[Math.floor(Math.random()*(a.length-1))]+` | `+a[Math.floor(Math.random()*(a.length-1))]+` | `+a[Math.floor(Math.random()*(a.length-1))])

i did it that way to show it similar to the original, for ease of comprehension... but i would shorten it a bit with a loop, like this...

js
$(user), you played slots and got $(eval a=`$(urlfetch whateverLink)`.split(`,`);b=``;c=0;while(c<5){b+=a[Math.floor(Math.random()*(a.length-1))];if(c<4){b+=` | `};c++};b)

oh shit, my bad, i missed the last part of that message the first time... u can change it around to add the !addpoints directly in the response like this...

js
$(eval a=`$(urlfetch whateverLink)`.split(`,`);b=[];c=0;m=`you played slots and`;w=``;while(c<5){b[c]=a[Math.floor(Math.random()*(a.length))];c++};if(b[0]==b[1]&&b[0]==b[2]&&b[0]==b[3]&&b[0]==b[4]){m=`10 cause you just`;w=`!addpoints `};`${w}$(user) ${m} got ${b.join(` | `)}`)

i didn't notice it before, i just copy pasted that part, but u were only getting the first 3 of your 4 emotes cause u had "a.length-1" in the random statement... the random statement already does -1 one from the number u put there, for example "Math.floor(Math.random()*100)" will give u zero to 99... so u'll usually see it with a plus 1 at the end like this "Math.floor(Math.random()*100)+1" to get 1 to 100 instead ;)

edit:... oops, for some reason i thought u had an output of 5 emotes per slot spin... here, this'll do it with the 3 like u had, lol, sorry about that

js
$(eval a=`$(urlfetch whateverLink)`.split(`,`);b=[];c=0;m=`you played slots and`;w=``;while(c<3){b[c]=a[Math.floor(Math.random()*(a.length))];c++};if(b[0]==b[1]&&b[0]==b[2]){m=`10 cause you just`;w=`!addpoints `};`${w}$(user) ${m} got ${b.join(` | `)}`)

Didn't find your answer? The community is on Discord.

Ask on Discord