Closed ghost closed 11 years ago
i notice that you have some event listeners inside of other event listeners, like where you have a bot.on('newsong' inside of your vote skipping code. i don't know if that's allowed but you might wanna try separating all your event listeners as number 1.
if that doesn't work you can try something like this
bot.on('ready', function(data)
{
process.setMaxListeners(0);
});
you can read about it in the documentation here: http://nodejs.org/api/events.html
i wasn't able to reproduce this error no matter how many event listeners i added to my bot, not sure if that means its already built-in to ttapi or what, but by default node throws this error once you exceed 10 event listeners.
There's nothing technically wrong with setting a listener (using .on('something', ...)
) inside of an event handler. You can do this at any time. However, if your event handler is called multiple times you'll be adding a new listener for the something
event each time your handler runs. Sooner or later (sooner for you, I guess) you'll run into the limit that you describe here.
It's true that you could resolve this by removing the listener(s) first. This is unnecessarily complex. As @samuri51 says, a simpler and cleaner solution is to set up the listener just once, outside of any event handlers.
OK, Thanks for the help and @samuri51, the newsong event for the vote skipping code resets the array for the next song.
I just got this error message when running my bot on Cloud9.
Trace: at Bot.EventEmitter.addListener (events.js:168:15) at Object. (/var/lib/stickshift/51d1c5aa5973cae5750000b5/app-root/data/544956/node_modules/chat_bot.js:1024:5) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Code: