diff --git a/lib/channel/voteskip.js b/lib/channel/voteskip.js index 171a4281..28eb5bb2 100644 --- a/lib/channel/voteskip.js +++ b/lib/channel/voteskip.js @@ -14,6 +14,15 @@ VoteskipModule.prototype.onUserPostJoin = function (user) { user.socket.on("voteskip", this.handleVoteskip.bind(this, user)); }; +VoteskipModule.prototype.onUserPart = function(user) { + if (!this.poll) { + return; + } + + this.unvote(user.ip); + this.update(); +}; + VoteskipModule.prototype.handleVoteskip = function (user) { if (!this.channel.modules.options.get("allow_voteskip")) { return; @@ -44,6 +53,14 @@ VoteskipModule.prototype.handleVoteskip = function (user) { this.update(); }; +VoteskipModule.prototype.unvote = function(ip) { + if (!this.poll) { + return; + } + + this.poll.unvote(ip); +}; + VoteskipModule.prototype.update = function () { if (!this.channel.modules.options.get("allow_voteskip")) { return; diff --git a/lib/user.js b/lib/user.js index d82727d6..e450829e 100644 --- a/lib/user.js +++ b/lib/user.js @@ -175,8 +175,8 @@ User.prototype.setAFK = function (afk) { if (afk) { this.setFlag(Flags.U_AFK); - if (this.channel.voteskip) { - this.channel.voteskip.unvote(this.ip); + if (this.channel.modules.voteskip) { + this.channel.modules.voteskip.unvote(this.ip); } } else { this.clearFlag(Flags.U_AFK);