Sentencia IF en $eval

Asked Oct 23, 2020·8 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.

Hola, tengo un comando que genera un numero aleatorio del 1 al 25 y quiero que al genera un valor menos de 8 aparezca un mensaje y cuando es superior otro.
Mi duda es como puedo añadir un if al comando eval o tengo que poner en link de otro fichero.

gracias

8 replies

Try this:

$(eval R=Math.floor(Math.random()*25+1);R<8?`RESPONSE_FOR_LESS_THAN_EIGHT`:`RESPONSE_FOR_EIGHT_OR_MORE`)

Perfecto, muchas gracias por tu ayuda

One question, I already have the command created but how can I show the value of R next to the message

R<8?$R RESPONSE_FOR_LESS_THAN_EIGHT: $R RESPONSE_FOR_EIGHT_OR_MORE)
or how would it be done?
thanks

Type ${R} where ever you want the number to show in the message

Hello,
I currently have the command like this
!addcom !pruebas $(user) ha dormido $(eval R=Math.floor(Math.random()*25+1);R<8?"${R} horas eres un noob debes entrenar más":"${R} horas estamos orgullosos de ti no tenemos mas que enseñarte")

and it doesn't show me the value of R, need to indicate something else?
thanks

You should be using “ \` ” instead of “ \" ”

I can't get it to show me the value of the $ {R} field, could you tell me how the code would look?
thanks

Thanks! It worked! I didn’t know that normal apostrophes wouldn’t work.

Didn't find your answer? The community is on Discord.

Ask on Discord