Random Response From 2 Separate Response Pools

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.

Hey @kittymeowmeowkat!

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!

1 Like

This worked perfectly! Thank you! :smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.