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?
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])