How to make a command of a random number

Asked Oct 23, 2020·3 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

I have 2 doubts. First, how to create a command that choose a random number between 1 and 140. And the other doubt is if I can make that:
If the number is between 1-69, it says "Definitivamente eres tonto.",
if the number is between 70-79 it says "Pues eres bastante tonto, aunque podría ser peor."
If the number is between 80-89 it says "Estás por debajo del promedio.".
If the number is between 90-109 it says "Eres parte del promedio, te salvaste con suerte!".
If the number is between 110-119 it says "Estás por encima del promedio, pero tampoco tanto"
If the number is between 120-129 it says "Casi eres un Einstein en 2020, pero no llegas a serlo.".
If the number is between 130-140 it says "Eres un Einstein en pleno 2020, y la gente con tanto IQ como tu se queda hasta el final del stream paaa". I don't know if this can be made, but If it is possible, please help me. If not, just help me on the first doubt. Thank you!

3 replies

Try this, I hope this will work.

$(eval
x = Math.floor((Math.random() * 140) + 1);
if ( x <= 69 ) {
"Definitivamente eres tonto."
} else if ( x >= 70 && x <= 79 ) {
"Pues eres bastante tonto, aunque podría ser peor."
} else if ( x >= 80 && x <= 89 ) {
"Estás por debajo del promedio."
} else if ( x <= 90 && x >= 109 ) {
"Eres parte del promedio, te salvaste con suerte!"
} else if ( x <= 110 && x >= 119 ) {
"Estás por encima del promedio, pero tampoco tanto"
} else if ( x <= 120 && x >=129 ) {
"Casi eres un Einstein en 2020, pero no llegas a serlo."
} else if ( x >= 130 ) {
"Eres un Einstein en pleno 2020, y la gente con tanto IQ como tu se queda hasta el final del stream paaa"
}
)

It says the maximum characters is 500 and that is beyond it. If you cannot put the text depending on the number, then I would like to know how to simply get a random number from 1 to 140. Thank you very much!

@Calm Jellyfish Heya, I was thinking that how will you make it possible, as there is a word limit. Anyway, I shorten the code for you.

Exactly copy-paste the same code. It will work.

`----------------------------------------------------`
EXTRA:
For generating a random number from range 1 to 140, here's the code.
```$(eval Math.floor((Math.random() * 140) + 1)```
For generating a random number from range `<min>` to `<max>`, here's the code.
```$(eval Math.floor(Math.random() * (<max> - <min>) ) + <min>)```
Replace with your desired number in `<max>` and `<min>`. Note: do NOT include angular brackets (`<`, `>`)
Hope this query will help. `:)`