Random number generation

Hi, i need help on how to get a random number i have made a mock up thing of what I need I to so could someone make a translation to my discord bot and tell me how to do it

– means tab

client.on(“message”, message => {
if(message.content === ".hi
") {
–rn = random number generated(1-10)
–if rn = 5){
----if rn = 4{

using discord.js

JavaScript has a standard function Math.random() that returns a number greater than or equal to 0, but less than 1. You can multiply that out to get a range and use Math.floor() to round it down to the number below.

For example, Math.floor(Math.random() * 10) gives a random number from 0 to 9. Adding 1 will give you a number from 1 to 10.


Thanks man you saved me

Hi @Fastflint_Minecraft,

If you found @JBYoshi’s post useful, kindly mark it as the “Solution” to this thread!

Solution GIF