tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.54k stars 216 forks source link

fail condition ? #424

Closed HeadShootPxG closed 3 years ago

HeadShootPxG commented 3 years ago

Hello,

I would like to respond to a specific person and only when he writes a sentence that I have defined.

I think I did it wrong

if someone can tell me how to proceed

if (displayName == 'myname' && message.indexOf("Im going to win")) { client.action(target,"GG !"); } unfortunately as soon as I write with the nickname defined it sends GG directly without checking the sentence

AlcaDesign commented 3 years ago

You want to use str.includes (MDN) not str.indexOf. indexOf will return 0 through str.length - 1 if the test value is in the string and -1 if it's not. includes will return true or false.

The tmi.js issues are not for programming questions. Please use MDN, StackOverflow, the "Twitch API" community Discord (#general-javascript), or the official TwitchDev Discord (#javascript-and-node) for general JavaScript support.