2 differents answers depending if command is in stream title or not

Hi all !

I would like to create a 2 variable command with nightbot. I would have 2 different answer depending on whether the command is write in the title of the stream or not.

An example with “!test” command :
Stream title 1 : New live today, welcome all
:arrow_right: In this case, if i type “!test” on the chat, nightbot answer : “non avaliable request”
Stream title 2 : New live today, welcome all | Write !test on chat
:arrow_right: In this case, if i type “!test” on the chat, nightbot answer : “This is a test !”

Big thank for your help programmers :blush: !

$(eval t=“$(twitch channel)”; if(t.includes(“!test”)){“this is a test”}else{“no avaliable request”))

Hey @mrnemod thanks for your help !

Unfortunately, it’s not working, Nightbot always answer “Invalid or unexpected token)” :cry:

$(eval t=“$(twitch Channel “{{title}}”)”;if(t.includes(“!test”)){“this is a test”;}else{“no available request”;})

Sorry mb

Hey @mrnemod!

I’ve tried it but it’s not working :confused:
Nightbot still responds “Invalid or unexpected token”

But i’ve tried to replace all " by backticks : $(eval t=$(twitch Channel {{title}});if(t.includes(!test)){this is a test;}else{no available request`;} )

and it’s half working ^^ , now nightbot always answer “no available request”

I thing we are close !
Thanks for your help !

Hey @monsieurtu!

Here’s the fix to @mrnemod’s command that works, as well as a quick simplification thanks to syntactic sugar:

$(eval '$(twitch $(channel) "{{title}}")'.includes('!test') ? 'this is a test' : 'no available request';)

:warning: $(channel) must remain as such, it’s a variable.

The issue was that you were using the wrong double quotes: “” instead of ", I personally prefer using single quotes ' they’re faster to type and look cleaner — the only exception is inside of the Twitch variable, there are double quotes " because they are required according to the documentation — and I use backticks ` only when I combine variables with text.
You were close, good job!


Hi @Emily!

Yeah it works perfectly, you’re still the boss here :smile: ! Thanks!
And thank you for your explanations, it’s interesting !

Thanks @mrnemod too ! We were close !

See you !

1 Like

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