diff --git a/lib/irc.js b/lib/irc.js index 0ad258a3..a24f2489 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -545,12 +545,12 @@ function Client(server, nick, opt) { // handle other people quitting channels = []; - - // TODO better way of finding what channels a user is in? Object.keys(self.chans).forEach(function(channame) { var channel = self.chans[channame]; - delete channel.users[message.nick]; - channels.push(channame); + if (message.nick in channel.users && typeof channel.users[message.nick] !== 'undefined') { + delete channel.users[message.nick]; + channels.push(channame); + } }); // who, reason, channels