Random Response From 2 Separate Response Pools

Asked Nov 23, 2020·2 replies·Last activity 5 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.

I've got a nightbot that we want to be able to do a response where IF there is a target mentioned, it will take responses from pool A. IF there is NO target, it will take responses from pool B. Examples below:

Example 1) BOB enters > !command OTHER-USER
Bot Responds > BOB has fought OTHER-USER and (won, lost, etc).

Example 2) BOB enters > !command
Bot Responds > BOB has fought (God,Cthulhu, etc) and (lost, won, etc).

We have the basic bones of the bot, but I wanted to see if pulling from two sets of different responses is possible.

2 replies

Hey @Swanky Otter!

Yes, it's possible, we simply test if $(touser) is equal to $(user) or not.

!addcom !fight $(eval e=[`Enemy1`,`Enemy2`,`Enemy3`];o=[`won!`,`lost...`,`it's a tie!`];r=x=>x[Math.floor(Math.random()*x.length)];`$(user) has fought ${`$(touser)`==`$(user)`?r(e):`$(touser)`} and ${r(o)}`)

Replace the Enemies and you're good to go!

This worked perfectly! Thank you! 😄