NightDev Community Forums

Random number generator command with custom input

Does anyone know how I would add a command that generates a random number based on two numbers provided by the user?

I want a command with a syntax like this:
!rng <minimum number> <maximum number>
So, for instance, if you used !rng 8 342, it’d give you a random number between 8 and 342.

It’d also be nice if it defaults to 1–100 if no variable is inputted by the user.

Does anyone know if something like this is possible? I do know from the docs that you can have a command that gives you a random number between two specific numbers, but I don’t know how I’d create a command that lets the user choose the number range as I currently have little experience with JavaScript.

Any help is highly appreciated!


!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))

For a random number between a specific minimum and maximum:

!rng [min] [max]

For a random number between 1 and 100:


Works perfectly! Thank you again for the quick reply!