kritzware/twitch-bot

Possible Error in Example?

Closed this issue ยท 3 comments

Hey there - loving twitch-bot as it's so easy to use, but I think I've found an issue in the example.

When I use the following code from the documentation:-

Bot.on('join', () => {

  Bot.on('message', chatter => {
    if(chatter.message === '!test') {
      Bot.say('Command executed! PogChamp')
    }
  })
})

...the listener is created every time someone joins the channel. So when four people are in the room and someone says "!test", 'Command executred! PogChamp' is posted to the room four times.

I've gotten around it by taking the listener out of the Bot.on('join') block and everything is working fine. Just not sure if the doc is unclear or if I'm reading it incorrectly is all!

Hi, glad to hear your enjoying the package!

I'm going to take a look into this issue, thanks for reporting it ๐Ÿ‘

Hi @SuperKMx - This was an issue with the way we parse irc JOIN events. I've just released a fix for this and pushed it to NPM. Make sure you update to the latest version 1.2.4 ๐Ÿ‘

Will do - thanks, @kritzware for the prompt fix!