fix: multiple end announcements after reroll

This commit is contained in:
Davide Fantino 2023-02-25 11:55:08 +01:00
parent 106ae758b2
commit 42bdb8484b

View File

@ -202,6 +202,7 @@ export default class MapVote extends DiscordBasePlugin {
this.or_options = { ...this.options }; this.or_options = { ...this.options };
this.autovotestart = null; this.autovotestart = null;
this.lastMapUpdate = new Date(); this.lastMapUpdate = new Date();
this.endVotingTimeout = null;
this.timeout_ps = [] this.timeout_ps = []
this.onNewGame = this.onNewGame.bind(this); this.onNewGame = this.onNewGame.bind(this);
@ -252,7 +253,8 @@ export default class MapVote extends DiscordBasePlugin {
async onNewGame() { async onNewGame() {
for (let x of this.timeout_ps) clearTimeout(this.timeout_ps.pop()) for (let x of this.timeout_ps) clearTimeout(this.timeout_ps.pop())
setTimeout(async () => {
this.endVotingTimeout = setTimeout(async () => {
this.endVoting(); this.endVoting();
this.trackedVotes = {}; this.trackedVotes = {};
this.tallies = []; this.tallies = [];
@ -743,6 +745,7 @@ export default class MapVote extends DiscordBasePlugin {
this.votingEnabled = false; this.votingEnabled = false;
clearInterval(this.broadcastIntervalTask); clearInterval(this.broadcastIntervalTask);
clearTimeout(this.newVoteTimeout); clearTimeout(this.newVoteTimeout);
clearTimeout(this.endVotingTimeout);
this.newVoteTimeout = null; this.newVoteTimeout = null;
this.broadcastIntervalTask = null; this.broadcastIntervalTask = null;
} }