NightDev Community Forums

Generate a Random number

Hi, I’m from Argentina … I’m new to Nightbot and I want to generate a random number between two ranges of numbers. for example 1-10 and 50-60 …

help me pls

Heya, try this…

$(eval const r= [’$(eval Math.floor((Math.random() * 10) + 1))’, ‘$(eval Math.floor((Math.random() * 10) + 51))’]; r[Math.floor(Math.random() * r.length)]:wink:

Well if you want any other use this

Math.floor((Math.random() * (max_num - min_num) + min_num + 1)

I hope it will work… And please ignore my logic :no_mouth::sweat_smile::shushing_face:

1 Like

Thanks for your answer!! but the command doesn’t work ): , Nightbot says “Invalid or unexpected token” in chat

Ahh you know what… That was not my fault… Lemme explain… If you type [ ; ) ] without space it will turn into [:wink:] this emote… See at the last

Copy this… I hope this will work

$(eval const r= ['$(eval Math.floor((Math.random() * 10) + 1))', '$(eval Math.floor((Math.random() * (10)) + 51))']; r[Math.floor(Math.random() * r.length)]; )

1 Like

it works now!! thank you thank you :smile: @Ritik_Ranjan