Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
I want my embed colour to be set between 2 different colours

So currently, I have a piece of code which chooses yellow to set as the colour of the embed.

.setColor('YELLOW')

This works fine and sets the colour of the embed to yellow. With my limited knowledge of js, I figured that adding || which is the logical OR operator, it would allow the bot to choose between either yellow or another colour. So I changed the code to this:

.setColor('YELLOW' || 'RED')

When I tested this code, it didn't work. It just kept the colour to yellow. I tried saving the file multiple times. I also allowed the bot to go offline and then retired it, to no avail. Could someone help me out, please?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The OR (||) operator always returns the first truthy value, YELLOW in your case.

If you only want to choose between those two, you can put them in an array and use Math.random() to generate a random number. If this number is less than 0.5, you can choose the first one, if it's larger, choose the second one:

console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])

You can update your code like this:

.setColor(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda