How can i add the ability to @ someone to a command?

I use this code currently for the first person in my chat to use. and when they do !first nightbot will call up how many times they’ve gotten !first +1. As it is, the command has to be used by the person who wants their list to have +1 added. I am trying to have the command work where id do !first @user and it would respond “User Has arrived First X+1 times.” Right now if i do !first @user it will call my list and add 1 to my list not the @'ed person. Thanks for your time!

!first
$(eval C=$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLICTOKEN&no_id=1).split(,);A=$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATETOKEN&data=$(user),);x=0;for(i=0;i<C.length-1;i++){if(C[i]==$(user)){x++}};$(user) has arrived First ${x+1} times!)

well, i see 2 ways to do it… could simply switch every $(user) to $(touser)… but that would allow anybody to add anybody else… if u wanna safeguard it so that only u and/or mods can do it u can switch the name of that command (i would do “!firstpart2”, some would do “_first”, but it doesn’t really matter, u could name it “purple” if u wanted, lol, as long as u link the new command i’m about to give u to it and name the new one “!first”) and then add this as !first …

$(eval let a=`$(userlevel)`[0].toLowerCase;a==`o`||a==`m`?`$(touser)`:`$(user)`)

and change every $(user) in the one u have to $(1) instead of $(touser)
p.s. don’t forget to add the one u already have renamed in the alias box near the bottom

Thank you for the suggestions! These are perfect! I definitely would want to go with the more safeguarded option. This is what I ended up with and after testing on twitch, it worked perfectly as far as I could tell.

!first
$(eval let a=$(userlevel)[0].toLowerCase;a==o||a==m?$(touser):$(1))
w/ Alias “!first2”

!first2
$(eval C=$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLICTOKEN&no_id=1).split(,);A=$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATETOKEN&data=$(1),);x=0;for(i=0;i<C.length-1;i++){if(C[i]==$(1)){x++}};$(1) has arrived First ${x+1} times!)

Note:
It wasn’t working quite right with the code you provided verbatim and I changed the “$(user)” at the very end to “$(1)” to give me my final result that seems to be working!

Thanks so much for your help!

just curious… what was the “not quite right” part?.. cause that modification u made negated the whole thing… now only mods and streamer can check their own name (and others’ names) and the viewers can ONLY check other people’s names…

i’ve reverted it back to the verbatim code you have

$(eval let a=$(userlevel)[0].toLowerCase;a==o||a==m?$(touser):$(user))

and when i do !first it replies with how many time i’ve gotten first +1 but when i do !first @OtherUser it replies with how many times I have gotten first +1 not the Other User

So as of now my code set up is

!first
$(eval let a=$(userlevel)[0].toLowerCase;a==o||a==m?$(touser):$(user))
w/ Alias “!first2”

!first2
$(eval C=$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLICTOKEN&no_id=1).split(,);A=$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATETOKEN&data=$(1),);x=0;for(i=0;i<C.length-1;i++){if(C[i]==$(1)){x++}};$(1) has arrived First ${x+1} times!)

lol, oops, i forgot the () after toLowerCase my bad XD… so it should look like this…

$(eval let a=`$(userlevel)`[0].toLowerCase();a==`o`||a==`m`?`$(touser)`:`$(user)`)

and the other one is perfect

1 Like

should the command allow for regular users (non mod/owner) to use the command?

When i tested it I could @otheruser and it would work as intended. it would respond @OtherUser has gotten first x+1 times.

When i tested it with a normal user, they could still do !first for themselves (not with the @someone) is that intentional?

yes, that’s the safeguard, to prevent the viewers from randomly adding to other people’s quantity… could also modify it so that anybody could check the values without adding to them, but let mods and streamer add to them or not ^^

ah okay!
Having it so anyone could check their values without adding to them and having it so only mods/streamer can add to the value would be ideal!

oh, well that’s even easier than what i said… just gotta move your private token and tweak a little… like this…

$(eval let a=`$(userlevel)`[0].toLowerCase();a==`o`||a==`m`?`$(touser) PRIVATE_TOKEN 1`:`$(user) 0 0`)

so move the private token there and where the private token currently is, change it to $(2) so it looks like…
...?token=$(2)&data=$(1)...
and then change ${x+1} to ${x+$(3)}

p.s. if u wanted viewers to be able to check each other’s but not add to it u could use this one instead…

$(touser) $(eval let a=`$(userlevel)`[0].toLowerCase();a==`o`||a==`m`?`PRIVATE_TOKEN 1`:`0 0`)

This is where im at

!first
$(touser) $(eval let a=$(userlevel)[0].toLowerCase();a==o||a==m?PRIVATE_TOKEN:0 0)

!first2
$(eval C=$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLICTOKEN&no_id=1).split(,);A=$(urlfetch https://twitch.center/customapi/addquote?token=$(2)&data=$(1),);x=0;for(i=0;i<C.length-1;i++){if(C[i]==$(1)){x++}};$(1) has arrived First ${x+$(3)} times!)

It’s hard to explain but it’s not working right. A basic user was able to add to the owners number with an @. and a basic user was able to just do !first and have it add 1, but then having the same basic user do !first @theowner it wouldnt add 1 like it had just done.

Also this is a sequence that happened
as creator:
!first @thecreator
Creator had arrived first x times (no +1)
!first (no @)
Creator had arrived first x+1 times
!first @thecreator
Creator had arrived first x+1 times

i think i forgot a space and a 1? after the PRIVATE TOKEN could that be it?
$(touser) $(eval let a=$(userlevel)[0].toLowerCase();a==o||a==m?PRIVATE_TOKEN 1:0 0)

so should it look like this?

EDIT:
It looks to be working! so only creator/mod can add +1 with an @anyone
Creator also cannot check their own, when creator does !first or !first @creator it will +1 the number (which i guess doesnt matter much cuz its more for the viewers)

but user seems to be working where !first will give their own with no +1 and they can do !first @anyuser and it’ll show their number x with no +1

Could we make it so mods could also check their own scores without adding 1?

glad u caught the space and 1, lol… and yes, we can… like this…

$(touser) $(eval let a=`$(userlevel)`[0].toLowerCase(),b=`$(query)`.toLowerCase().split(` `);a==`o`||a==`m`?`${b[b.length-1]==`check`||b[b.length-1]==`chk`?`0 0`:`PRIVATE_TOKEN 1`}`:`0 0`)

with this, it defaults to adding one, but if u type “check” or “chk” at the end of whatever else u type, it will check it without adding one

with this, when i as the creator do !first @myself check
it comes back saying 0 but when i do a !first it says my accurate x amount of times +1 so it just keeps saying i have 0 (but again i guess this doesnt matter cuz the creator doesnt check in XD)

I was correctly able to do “!first @user check” and get the user’s number without +1

and users were able to !first to check themselves and !first @user to check theirs

EDIT
it seems that the count is case sensitive? so like !first @thewitchling will be 0 but !first @TheWitchling will be X

is it possible to have it work both ways? so upper or lower case will call the same X?

EDIT
yeah im pretty sure the part about my score coming back 0 was because of the upper case vs lower case name

um, if u got that version right away, i had made a slight error, but i fixed it shortly after… double check u have the updated version before we try to troubleshoot… case sensitivity for the username shouldn’t effect it, that may just be it seeing the name and not seeing it, hard to tell without being sure u have the updated version

p.s. oh wait… nvm, yeah, that can make a difference… because it’s saved in the list with your display name… um… i’m not sure it will work, but we can try to get that… it appears to take it as a string, so it should work…
so, to do that, on the second command u’d need to change

&no_id=1)`.split

to

&no_id=1)`.toLowerCase().split

and then…

$(eval let a=`$(userlevel)`[0].toLowerCase(),b=`$(query)`.toLowerCase().split(` `),c=`$(touser)`.toLowerCase();a==`o`||a==`m`?`${b[b.length-1]==`check`||b[b.length-1]==`chk`?`${c} 0 0`:`${c} PRIVATE_TOKEN 1`}`:`${c} 0 0`)

for the first one

so far with my testing it seems to be working perfectly. if you want i can provide the final code i have to show. otherwise it’s working great! thanks so so much for your help through all of this!

1 Like

lol, no problemo… this is fun for me, better than playing a game ^^

1 Like

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