diff --git a/channel.js b/channel.js index dd9f0757..8040a459 100644 --- a/channel.js +++ b/channel.js @@ -326,7 +326,10 @@ Channel.prototype.userLeave = function(user) { if(this.leader == user) { this.changeLeader(""); } - this.users.splice(this.users.indexOf(user), 1); + var idx = this.users.indexOf(user); + if(idx >= 0 && idx < this.users.length) + this.users.splice(idx, 1); + console.log(this.users.length); this.updateUsercount(); if(user.name != "") { this.sendAll('userLeave', { diff --git a/chatcommand.js b/chatcommand.js index 50dfd646..498b6104 100644 --- a/chatcommand.js +++ b/chatcommand.js @@ -33,7 +33,6 @@ function handleKick(chan, user, args) { } if(kickee) { kickee.socket.disconnect(); - chan.userLeave(kickee); } } } @@ -50,7 +49,6 @@ function handleBan(chan, user, args) { if(kickee) { chan.ipbans.push(kickee.ip); kickee.socket.disconnect(); - chan.userLeave(kickee); } } }