Viewers gender counters

I saw this command to make an counter for ppl in the stream to tally up boys and girls. I tried to make another variable to include others but I can not figure it out. Can you please help. Im am trying to code this using nightbot. The link below is the original person who made it.

Here is the orginal code

$(eval a=$(urlfetch$(1));a=$(urlfetch json;b=a.match(/~B~/g);b=b!=null?${b.length} boys:0 boys;c=a.match(/~G~/g);c=c!=null?${c.length} girls:0 girls;if($(1).includes(PRIVATETOKEN)){d=$(3)==boys?b:c;$(user) ${d} have joined this stream. Cheers $(3) squad!;}else{$(user) ${b} and ${c} are watching this stream. Use !boy or !girl to join your squad.;})

This is my code trying to include others

$(eval a=$(urlfetch$(1));a=$(urlfetch json;b=a.match(/~B~/g);b=b!=null?${b.length} man:0 man;c=a.match(/~G~/g);c=c!=null?${c.length} woman:0 woman;o=a.match(/~X~/x);o=o!=null?${o.length} other:0 other;if($(1).includes(PRIVATETOKEN)){d=$(3)==boys?b:c:x;$(user) ${d} have joined this stream. Cheers $(3) squad!;}else{$(user) ${b} and ${c} and ${x} are here.;})

Hey @AlmghtyBLAIR!

Thank you for including the topic you’re basing yourself on!
I’ll re-write big chunks of the code, but that gives me a good base to start with.

And I’m always happy to make code more inclusive, on that note, I suggest replacing the term “other” with “non-binary” since it’s an umbrella term for anyone who isn’t in the gender binary, so neither a woman nor a man, could be in-between or outside.

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:


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.

  • !woman:

    $(eval u='u#$(user)'; re = new RegExp(u, 'i'); m = `$(urlfetch json`.match(re); m === null ? `PRIVATE_TOKEN&data=${u}|g#W` : 'error';)
  • !man:

    $(eval u='u#$(user)'; re = new RegExp(u, 'i'); m = `$(urlfetch json`.match(re); m === null ? `PRIVATE_TOKEN&data=${u}|g#M` : 'error';)
  • !enby:

    $(eval u='u#$(user)'; re = new RegExp(u, 'i'); m = `$(urlfetch json`.match(re); m === null ? `PRIVATE_TOKEN&data=${u}|g#E` : 'error';)

    :warning: Set the alias of these three commands above to _addGender

  • _addGender:

    $(eval a=`$(urlfetch$(query))`;l=`$(urlfetch json`;u='$(user)';q='$(query)'.split('|');if(q.length>0){q=q[1];q=='g#W'?g='women':q=='g#M'?g='men':g='enbies';re=new RegExp(q,'g');n=l.match(re).length;a.includes('Successfully')?u+` → ${n} ${g} joined this stream. Cheers ${g} squad!`:u+` → There was an error, try again.`}else{`You're already in the list ${u}, use !genders instead.`})
  • !genders, the command to call to have the total:

    $(eval l = `$(urlfetch json`; gW = l.match(/g#W/g)?.length || 0; gM = l.match(/g#M/g)?.length || 0; gE = l.match(/g#E/g)?.length || 0; `$(user) → There are ${gW} women, ${gM} men, and ${gE} enbies watching the stream!`;)

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