diff --git a/README.MD b/README.MD index aa1a7e2..125cc7d 100644 --- a/README.MD +++ b/README.MD @@ -11,6 +11,7 @@ The `MapVote` plugin for squad js based on the original version https://github.c #### Admin Commands - `!vote start` - Starts a vote with 6 layers, random modes - `!vote cancel` - Cancels current round of voting +- `!vote cancelauto` - Cancel scheduled automatic start of vote - `!vote restart` - Restarts voting with 6 random maps and modes - `!vote broadcast` - Broadcasts current voting results - happens every 7m automatically diff --git a/mapvote.js b/mapvote.js index 76a5cbe..be48c79 100644 --- a/mapvote.js +++ b/mapvote.js @@ -139,6 +139,7 @@ export default class MapVote extends DiscordBasePlugin { bypassRaasFilter: false }; this.or_options = { ...this.options }; + this.autovotestart = null; this.onNewGame = this.onNewGame.bind(this); this.onPlayerDisconnected = this.onPlayerDisconnected.bind(this); @@ -183,7 +184,7 @@ export default class MapVote extends DiscordBasePlugin { this.tallies = []; this.nominations = []; this.factionStrings = []; - if (this.options.automaticVoteStart) setTimeout(this.beginVoting, toMils(this.options.voteWaitTimeFromMatchStart)); + if (this.options.automaticVoteStart) this.autovotestart = setTimeout(this.beginVoting, toMils(this.options.voteWaitTimeFromMatchStart)); setTimeout(() => this.setSeedingMode(true), 10000); }, 10000) } @@ -323,6 +324,17 @@ export default class MapVote extends DiscordBasePlugin { this.endVoting(); await this.warn(steamID, "Ending current vote"); return; + case "cancelauto": //cancels the current vote and wont set next map to current winnner + if (!isAdmin) return; + + if (!this.autovotestart) { + await this.warn(steamID, "There is no automatic vote start scheduled"); + return; + } + clearTimeout(this.autovotestart); + this.autovotestart = null; + await this.warn(steamID, "Ending current vote"); + return; case "broadcast": if (!this.votingEnabled) { await this.warn(steamID, "There is no vote running right now");