Conditional S/O Nightbot command

Hi I’m trying to make an if/than shoutout command that recognizes that the user hasn’t played a game, and therefore isn’t likely to stream…

I have no idea what I’m doing lol but after a few hours this is the closest I could come up with…

$(eval var r = true; if(‘twitch game $(touser)’ == ‘no game’) r = ‘They don’t stream’; else ‘check out $(touser) They were last playing $(twitch game $(touser))’:wink:

It’s not recognizing the “no game” like I thought it might…

Any help would be greatly appreciated!!

@astrohippieet I don’t know much about the JavaScript, as far I know. if else should be like this:

if (condition) {
  //  block of code to be executed if the condition is true
} else {
  //  block of code to be executed if the condition is false
}

Or there is a shortcut

condition ? exprIfTrue : exprIfFalse

In your case, it’s bit different. consider using toLowerCase(). Tho’ it’s not needed I guess.

$(eval “$(twitch game $(touser))”.toLowerCase() == “no game” ? “They don’t stream” : “Check out $(touser). They were last playing $(twitch game $(touser))”)

Regards

Edit

$(eval '$(twitch $(touser) "{{game}}")'.toLowerCase() == 'no game' ? 'They do not stream' : 'Check out $(touser). They were last playing $(twitch $(touser) "{{game}}")')
3 Likes

Quick error correction: it’s not $(twitch game $(touser)), but $(twitch $(touser) "{{game}}").

3 Likes

Thank you both so much, again I’m very new to this and made the original command by Frankenstein-ing some other commands I could find lol I appreciate it so much!

1 Like

It works! I can’t thank you enough Ritik :slight_smile: I commend you being able to wrap your head around this stuff, it was driving me crazy lol

2 Likes

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