Making this command plug in follow on "input"

!addcom -cd=5 !rng $(eval a=decodeURIComponent($(querystring)).split( ).map(a=>parseInt(a)).filter(a=>!isNaN(a));a.length==2&&a[1]>=a[0]?Math.floor(Math.random()*(a[1]-a[0]+1))+a[0]:Math.ceil(Math.random()*100))

^^^^allows people to do !rng (min) (max). What I’m trying to do is make it so that only certain viewers (Subs and non-subs) be able to do !rng (min) (max) of different kinds. For example, subs would be getting !rng with a higher (min) than normal viewers. Is there any way for me to set this up?

What I was trying to do was find a way to have the command contain a (min) (max) as I haven’t been able to figure out how to not let non-subs to give themselves the desired (min) (max) as I can’t simply do !rng subs x y as they’d still have to do !rng subs x y x y due to the first x y being part of the !rng command itself.

Any help would be greatly appreciated!!

I think I get what your asking and this could be achieved with use of the $(userlevel) variable nightbot provides just check what level the user is and set the min based off that.

I see, but how would I use $(userlevel) alongside this command and set the min as well? I get the $(userlevel) part but not sure how to set seperate (mins) for them.

Basically just check their user level like this:


Set min to what you want it to be then.
The different user levels are:”owner”,”moderator”,”twitch_vip”,”regular”,”subscriber”,”everyone”
They are ordered from highest to lowest owner will always take precedent over subscriber or everyone for example.

Thanks! I’ll look into how to make the two work together as I figured out what you put was just an example. Still learning this stuff after all lol xD

Yes it’s just an example if you need help making the command though just tell me how you want it to work. More specifically what number ranges you want it to output based on user level and whether or not they input a min and max number etc.

Wow, cool! If you’re free to do so. I just need two variants.
Subs get 25-120
VIPS get 15-110.

If it’s possible to do these it’d help me greatly!!

What do non vips get nothing? I’m just gonna write it so that every other variation gets an error message That means Owner, Regulars(if you have any), and Normal viewers will all get this message.

!editcom !rng $(eval var a=`$(userlevel)`;a==`moderator`?Math.floor(Math.random()*96)+15; a==`twitch_vip`?Math.floor(Math.random()*96)+15; a==`subscriber`?Math.floor(Math.random()*96)+25;`Only Moderators, Vips, and Subscribers can use this command`)

This should work
Note: I added moderators so they can use it they have the same rng as a vip.(Feel free to change) Also vips/mods who are subscribed will still only get 15-110 due to the way nightbot handles the user levels.

I just tried the command, was able to edit the command when executed but when using !rng to test it presents with: Unknown token ‘,’

Sorry for the late reply, was actually live lol.

I’m very sorry about that I used “;” instead of “:”

!editcom !rng $(eval var a=`$(userlevel)`;a==`moderator`?Math.floor(Math.random()*96)+15: a==`twitch_vip`?Math.floor(Math.random()*96)+15: a==`subscriber`?Math.floor(Math.random()*96)+25:`Only Moderators, Vips, and Subscribers can use this command`)

This should work

Thank you, it did! Going to have to wait till next stream tomorrow to see if my subs can help me test to see if it worked for them!! I’ll come back if there’s any errors. Thank you for even making this for me!!

1 Like

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