Sentencia IF en $eval

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

Try this:

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

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.