kritzware / twitch-bot

🤖 Easily create chat bots for Twitch.tv
https://www.npmjs.com/package/twitch-bot
MIT License
149 stars 36 forks source link

Possible Error in Example? #26

Closed SuperKMx closed 6 years ago

SuperKMx commented 6 years ago

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!

kritzware commented 6 years ago

Hi, glad to hear your enjoying the package!

I'm going to take a look into this issue, thanks for reporting it 👍

kritzware commented 6 years ago

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 👍

SuperKMx commented 6 years ago

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