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.
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)}`)