added cancelauto command

This commit is contained in:
Davide Fantino 2022-09-28 22:42:53 +02:00
parent c1e6f93aa7
commit 4339815acd
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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");