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

Asked Aug 20, 2022·6 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 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
➡️ 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
➡️ In this case, if i type "!test" on the chat, nightbot answer : "This is a test !"

Big thank for your help programmers 😊 !
Max.

6 replies

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

Hey @Stellar Boar thanks for your help !

Unfortunately, it's not working, Nightbot always answer "Invalid or unexpected token)" 😢

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

Sorry mb

Hey @Stellar Boar!

I've tried it but it's not working 😕
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 @Trusty Penguin!

Here's the fix to @Stellar Boar'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';)

⚠️ $(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 @Polar Cat!

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

Thanks @Stellar Boar too ! We were close !

See you !

Didn't find your answer? The community is on Discord.

Ask on Discord