'Discord.js random number

If you don't mind me asking, I've been trying to find out a way to have a discord user say (prefix)randomnumber and then 2 parameters like 1 10 and it picks a random number such as 7. Does anyone know of a way to do this in java script?



Solution 1:[1]

You can do like

Math.floor(Math.random()*second_parameter)+first_parameter

and if we take the full code

const args = message.split(' ')
if(args[0] === `${prefix}randomnumber`){
    message.channel.send(Math.floor(Math.random()*parseInt(args[2]))+parseInt(args[1]))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1