Conditional shoutout command

I want to create a text output that when the streamer is shouted out on their own channel nightbot gives a silly command

Something like this but I can’t get it to work at least with the conditional ? statement

$(eval $(touser) == ‘streamer username here’ ? ‘No, not allowed’ : ‘Check out $(touser). They were last playing $(twitch $(touser) “{{game}}”)’)

Hey @coltynphd!

There are a couple issues with your code:

  1. you use the wrong quotation marks: ‘’ and “” instead of ' and " respectively,
  2. you forget to put the first $(touser) inside quotation marks, therefore it’s considered an undefined variable and not a string,
  3. $(touser) is case sensitive, while $(channel) is in lower case, therefore '$(touser) == '$(channel)' will always be false if you made any of your username’s letter upper case.

With all that in mind, here’s the fix:

$(eval '$(touser)'.toLowerCase() === '$(channel)' ? 'No, not allowed' : 'Check out $(touser). They were last playing $(twitch $(touser) "{{game}}")')

Hi @Emily , thanks for the helpful and quick response. I tried incorporating the fixes you suggested and when I tried to do the whole custom message nightbot would output an unexpected identifier error. Not sure what variable would be unexpected in this case.

$(eval '$(touser)'.toLowerCase() === '$(channel)' ? 'No, not allowed, illegal' : 'twitchRaid twitchRaid twitchRaid $(touser) was last seen playing [$(twitch $(touser) "{{game}}")] Let's send some Kibbles love from us here at the Dog House to$(touser)')

That’s because of your shoutout sentence: Let's closes the string sooner than you want because of the apostrophe, therefore it confuses the code and breaks, you can fix that by adding a \ (backslash) before the apostrophe, so Let\'s or by putting the whole sentence between ` (backticks) instead of single quote marks.

1 Like

This is great, that fixed it. Thank you so very much <3

1 Like

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