User Based If/Else

I’m trying to make a custom IQ command that picks random numbers for the user. The thing is, I want floor/ceiling to be different for me than everyone else. I found a custom API that generates the number, it works except is doesn’t run the specific api for me vs other users. My code is here:

!editcom !iq $(eval var a = “$(user)”; if (a.toLowerCase() === “MYUSERNAME”) { “$(user) has an IQ of $(customapi$(1)&end=$(2))
”; } else { “$(user) has an IQ of $(customapi$(1)&end=$(2))
”; } )

I know the if/else recognizes my name because it shows the different emoji, but the custom API isn’t showing right as I’m getting numbers outside the range I’m supposed to be in for my username.

Is there a better way to write this?

Update: I didn’t realize that the code I pasted here just doesn’t work at all, and I seemed to have deleted the code that was working to an extent. Nonetheless, my problem is still the same. How do I get the if/else statement to grab the specific api based on the user that types the command?

Okay, I’m back to the original code I had, but it still doesn’t work the way I’m looking for. I’ll paste it below, and I’m not going to mess with it until someone else that is better at this does. It won’t let me repost the actual API, but it is the same as the original post.

!editcom !iq


if (‘$(user)’ === “CWBibbs”)
{“$(user) has an IQ of $(customapi PogChamp”}


{“$(user) has an IQ of $(customapi LUL”}

if your api is just getting a random number, i’d just get the random number in the code, should also give a slightly faster command response as nightbot won’t have to go bother the api and wait for the response… i’d make it look something like…

$(eval a=“$(user)”;b=300;c=150;d=" PogChamp";if(a.toLowerCase()==“cwbibbs”){b=69;c=1;d=" LUL"};e=Math.floor((Math.random()*(b-c+1))+c);a+" has an IQ of "+e+d)

of course a is the user, b is the highest random number (which if i read that right u wanted 300 highest for others and 69 highest for u), c is lowest random number (which if i read that right u wanted 150 lowest for others and 1 lowest for u), d is the emote choice and e is where it calculates the random number

Thank you! When I put that in and run it, I’m getting back Invalid or unexpected token. I just copied and pasted, so not sure why.

Also to clarify, I am looking for a range of 150-300 for me and 1-69 for others.

yeah, for some reason it changed some of the quotes to a different kinda character just go to the quotes around $(user) and around cwbibbs delete them and type a quote back in… also put an exclamation before the double == so it says !== and u’ll be all set

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