Create NightBot command help

Asked Aug 22, 2022·1 reply·Last activity 4 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.

Hello, I'm trying to make a command that prints a line from pastebin with a certain probability, for example 30%. If the other 70% worked, then a line from another pastebin is displayed.
The bottom line is that the user types a command, for example: !pun and a pun from https://pastebin.com/raw/7nHfBLkZ is displayed with a certain probability. Or if the probability did not work, the roast is displayed from https://pastebin.com/raw/LBAe9kQj.
What pastebin needs to be edited and separated with "|" I know and will do later. But I can't figure out how to do something like "If rng < 70; insert pun command here else; insert roast command here"

Please, help.

1 reply

Hey @Nimble Goat!

You can't call either of two commands following an if/else, but you can have different outputs, it'll just be within the same command.

If you're going to use the vertical line | as the separator — don't put one at the end of the last option — then this is how you make such command:

$(eval p = '$(urlfetch json https://pastebin.com/raw/7nHfBLkZ)'.split('|'); r = '$(urlfetch json https://pastebin.com/raw/LBAe9kQj)'.split('|'); Math.random() < 0.7 ? p[Math.floor(Math.random() * p.length)] : r[Math.floor(Math.random() * r.length)];)