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
:
$(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))
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 https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.match(re); m === null ? `PRIVATE_TOKEN&data=${u}|g#W` : 'error';)
-
!man
:$(eval u='u#$(user)'; re = new RegExp(u, 'i'); m = `$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.match(re); m === null ? `PRIVATE_TOKEN&data=${u}|g#M` : 'error';)
-
!enby
:$(eval u='u#$(user)'; re = new RegExp(u, 'i'); m = `$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`.match(re); m === null ? `PRIVATE_TOKEN&data=${u}|g#E` : 'error';)
Set the alias of these three commands above to
_addGender
-
_addGender
:$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;l=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`;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 https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`; 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!`;)