Conditional S/O Nightbot command

Asked Sep 1, 2021·4 replies·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.

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))';)

It's not recognizing the "no game" like I thought it might...

Any help would be greatly appreciated!!

4 replies

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

js
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

js
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}}")')

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

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!

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