Multiple touser variables

how do i make a command like !love but instead of the response being ‘love between user and touser’, i would like to be able to use the command for 2 tousers. something like ’ !love (user1) (user2). Is this possible? thanks in advance <3

@Matthias_Nijskens

You can use the argument variables $(1) and $(2)

@RokettoJanpu oh i see! how would i add that into this command correctly?

!addcom !love There is a $(customapi http://2g.be/twitch/randomnumber.php?=defstart=1&defend=100)% chance of love between $(user) and $(touser)

So that if i dont add 2 touser the command doesnt show $(touser) or $(2) in the response? or do i have to make a separate command? im sorry for the dumb question btw but i dont know anything about this :stuck_out_tongue:

Actually I have a similar command that doesn’t require a custom api to get a random number and uses querystring instead of touser to capture user input. It requires 2 usernames in the input in order for the command to have normal output.

!addcom -cd=5 !love $(eval a=decodeURIComponent(`$(querystring)`).split(` `);a.length==2?`There is a ${Math.ceil(Math.random()*100)}% chance of love between ${a[0]} and ${a[1]}`:`Enter 2 users`)
1 Like

@RokettoJanpu so theres no way i can get a working command where, if the user(me) specifies one touser, the user and the touser get included in the response but if the user (me) was to specify 2 tousers in the command those two would be included in the response and the user himself (me) is excluded? so basically a variable command with the same response for when there is 1 touser specified in the command and when 2 tousers get specified in the command. again sorry if my explanation is weird, i hope you understand my gibberish :smile: your command looks great btw! though it would be awesome if i didnt have to include myself in the command when i want to check the love % between me and one other person in chat in contrast to checking the love% between 2 people in chat, myself excluded. hope thats makes sense

Tweaked to allow 1 or 2 usernames in the input.

!addcom -cd=5 !love $(eval a=decodeURIComponent(`$(querystring)`).split(` `);a.length?`There is a ${Math.ceil(Math.random()*100)}% chance of love between ${a[0]} and ${a[1]||`$(user)`}`:`Enter at least 1 user`)
1 Like

this is perfect! you’re awesome man thank you so much! <3

also what kind of language is it that you used? is it php or javascript or something? looks fun to learn !

Yup it’s JavaScript! You can execute whatever code you want by putting it inside $(eval)

Thanks for helping man! Im gonna look more into coding, its quite interesting :slight_smile:

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