If/else with Math random

Asked Oct 30, 2023·1 reply·Last activity 2 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.

Hi
I want to make a command with a random number falling in the range from 0 to 100, and if it falls 100, then the bot writes one phrase, and if less, then another. help me please

1 reply

Hey @Warm Whale!

$(eval Math.floor(Math.random() * 101) === 100 ? 'NUMBER_EQUALS_100_SENTENCE' : 'DEFAULT_SENTENCE';)

If you need to use apostrophes in your sentence, you'll need to escape them, like this: \' (add a backslash before them).

Please use the search bar before opening a new topic, we covered this topic so many times before.