From 3ddc60cbf026950e40d9ceb64848d45f2489db86 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Sun, 15 Jan 2023 20:46:59 +0100 Subject: [PATCH 1/8] feat: ROUND_ENDED implemented & disabled next layer seeding mode --- mapvote.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mapvote.js b/mapvote.js index d2117c8..fb7108c 100644 --- a/mapvote.js +++ b/mapvote.js @@ -202,6 +202,7 @@ export default class MapVote extends DiscordBasePlugin { this.server.on('NEW_GAME', this.onNewGame); this.server.on('CHAT_MESSAGE', this.onChatMessage); this.server.on('PLAYER_DISCONNECTED', this.onPlayerDisconnected); + this.server.on('ROUND_ENDED', this.endVotingGently) setTimeout(() => { this.verbose(1, 'Enabled late listeners.'); this.server.on('PLAYER_CONNECTED', this.setSeedingMode); @@ -298,7 +299,7 @@ export default class MapVote extends DiscordBasePlugin { } } else this.verbose(1, "Bad data (currentLayer). Seeding mode for current layer skipped to prevent errors."); - if (this.server.nextLayer) { + /*if (this.server.nextLayer) { const nextMaps = seedingMaps.filter((l) => (!this.server.currentLayer || l.layerid != this.server.currentLayer.layerid)) let rndMap2; do rndMap2 = randomElement(nextMaps); @@ -308,7 +309,7 @@ export default class MapVote extends DiscordBasePlugin { const newNextMap = rndMap2.layerid; this.server.rcon.execute(`AdminSetNextLayer ${newNextMap} `); } - } else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors."); + } else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors.");*/ } else this.verbose(1, `Player count doesn't allow seeding mode (${this.server.players.length}/20)`); } else this.verbose(1, "Seeding mode disabled in config"); @@ -416,7 +417,7 @@ export default class MapVote extends DiscordBasePlugin { case "stopesqjs": case "restartsqjs": if (!isAdmin) return; - this.warn(steamID, "Saving persistent data.\nTerminating SquadJS process.\nIf managed by a process manager it will automatically restart.") + await this.warn(steamID, "Saving persistent data.\nTerminating SquadJS process.\nIf managed by a process manager it will automatically restart.") this.savePersistentData(); process.exit(0); return; @@ -642,9 +643,9 @@ export default class MapVote extends DiscordBasePlugin { this.broadcastIntervalTask = setInterval(this.broadcastNominations, toMils(this.options.voteBroadcastInterval)); } - endVotingGently() { + async endVotingGently() { this.endVoting(); - this.broadcast(this.options.voteWinnerBroadcastMessage + this.formatFancyLayer(Layers.layers.find((l) => l.layerid == this.updateNextMap()))); + await this.broadcast(this.options.voteWinnerBroadcastMessage + this.formatFancyLayer(Layers.layers.find((l) => l.layerid == this.updateNextMap()))); } endVoting() { From 4f78d480cee19800bcc9bc3858ecd8a8e8d21836 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Sun, 15 Jan 2023 22:53:35 +0100 Subject: [PATCH 2/8] feat: round ended implementation with discord logging --- mapvote.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/mapvote.js b/mapvote.js index fb7108c..25f7ab1 100644 --- a/mapvote.js +++ b/mapvote.js @@ -645,7 +645,53 @@ export default class MapVote extends DiscordBasePlugin { async endVotingGently() { this.endVoting(); - await this.broadcast(this.options.voteWinnerBroadcastMessage + this.formatFancyLayer(Layers.layers.find((l) => l.layerid == this.updateNextMap()))); + const winnerLayer = Layers.layers.find((l) => l.layerid == this.updateNextMap()); + const fancyWinner = this.formatFancyLayer(winnerLayer); + await this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner); + + if (!this.options.logToDiscord) return + return await this.sendDiscordMessage({ + embed: { + title: `Vote winner: ${fancyWinner}`, + color: 16761867, + fields: [ + { + name: 'Map', + value: winnerLayer.map.name, + inline: true + }, + { + name: 'Gamemode', + value: winnerLayer.gamemode, + inline: true + }, + { + name: 'Version', + value: winnerLayer.version, + inline: true + }, + { + name: 'LayerID', + value: winnerLayer.layerid, + inline: false + }, + { + name: 'Team 1', + value: winnerLayer.teams[ 0 ].faction, + inline: true + }, + { + name: 'Team 2', + value: winnerLayer.teams[ 1 ].faction, + inline: true + }, + ], + image: { + url: `https://squad-data.nyc3.cdn.digitaloceanspaces.com/main/${winnerLayer.layerid}.jpg` + }, + }, + timestamp: (new Date()).toISOString() + }); } endVoting() { @@ -760,7 +806,7 @@ export default class MapVote extends DiscordBasePlugin { async logVoteToDiscord(message) { if (!this.options.logToDiscord) return - await this.sendDiscordMessage({ + return await this.sendDiscordMessage({ embed: { title: 'Vote Started', color: 16761867, From 4c3b2ee895cd683ba261b5db7630be8d77ae4be6 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:21:23 +0100 Subject: [PATCH 3/8] fix: layer list && round ended callback --- mapvote.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mapvote.js b/mapvote.js index 25f7ab1..275f890 100644 --- a/mapvote.js +++ b/mapvote.js @@ -189,6 +189,7 @@ export default class MapVote extends DiscordBasePlugin { this.timeframeOptionOverrider = this.timeframeOptionOverrider.bind(this); this.savePersistentData = this.savePersistentData.bind(this) this.restorePersistentData = this.restorePersistentData.bind(this) + this.endVotingGently = this.endVotingGently.bind(this) this.broadcast = (msg) => { this.server.rcon.broadcast(msg); }; this.warn = (steamid, msg) => { this.server.rcon.warn(steamid, msg); }; @@ -917,9 +918,9 @@ export default class MapVote extends DiscordBasePlugin { async updateLayerList() { // Layers.layers = []; - this.verbose(1, 'Pulling [All For One] layer list...'); + this.verbose(1, 'Pulling updated layer list...'); const response = await axios.get( - 'http://hub.afocommunity.com/api/layers.json', [ 0 ] + 'https://raw.githubusercontent.com/Squad-Wiki/squad-wiki-pipeline-map-data/master/completed_output/_Current%20Version/finished.json' ); for (const layer of response.data.Maps) { From 8b73967b9691678b048fc8f3e3c505c0bb193580 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:05:29 +0100 Subject: [PATCH 4/8] chore: added showWinnerBroadcastMessage --- README.MD | 8 ++++++++ mapvote.js | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.MD b/README.MD index 66ef761..95c89ff 100644 --- a/README.MD +++ b/README.MD @@ -162,6 +162,13 @@ Message that is sent as broadcast to announce the winning layer. ```json "✯ MAPVOTE ✯\nThe winning layer is\n\n" ``` +#### showWinnerBroadcastMessage +###### Description +Enables the broadcast at the end of the voting. +###### Default +```json +true +``` #### allowedSameMapEntries ###### Description Allowed max NUMBER of times a map could appear in the vote list. @@ -241,6 +248,7 @@ Array of timeframes that allows to override options based on local time. See exa "showRerollOption": false, "voteBroadcastMessage": "✯ MAPVOTE ✯\nVote for the next map by writing in chat the corresponding number!", "voteWinnerBroadcastMessage": "✯ MAPVOTE ✯\nThe winning layer is\n\n", + "showWinnerBroadcastMessage": true, "allowedSameMapEntries": 1, "logToDiscord": true, "channelID": "112233445566778899", diff --git a/mapvote.js b/mapvote.js index 275f890..fc7df93 100644 --- a/mapvote.js +++ b/mapvote.js @@ -120,6 +120,11 @@ export default class MapVote extends DiscordBasePlugin { description: 'Message that is sent as broadcast to announce the winning layer', default: "✯ MAPVOTE ✯\nThe winning layer is\n\n" }, + showWinnerBroadcastMessage: { + required: false, + description: 'Enables the broadcast at the end of the voting.', + default: true + }, allowedSameMapEntries: { required: false, description: 'Allowed NUMBER of duplicate map entries in vote list', @@ -648,7 +653,7 @@ export default class MapVote extends DiscordBasePlugin { this.endVoting(); const winnerLayer = Layers.layers.find((l) => l.layerid == this.updateNextMap()); const fancyWinner = this.formatFancyLayer(winnerLayer); - await this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner); + if (this.showWinnerBroadcastMessage) await this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner); if (!this.options.logToDiscord) return return await this.sendDiscordMessage({ From 5b17f0961a25d6c4fca2a6011cb3d976dbd74cf9 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Sat, 21 Jan 2023 00:49:06 +0100 Subject: [PATCH 5/8] feat: main assets in voting list --- mapvote.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mapvote.js b/mapvote.js index fc7df93..fb0ca8c 100644 --- a/mapvote.js +++ b/mapvote.js @@ -151,6 +151,11 @@ export default class MapVote extends DiscordBasePlugin { description: "Timezone relative to UTC time. 0 for UTC, 2 for CEST (UTC+2), -1 (UTC-1) ", default: 0 }, + includeMainAssetsInBroadcast: { + required: false, + description: "Shows/Hides Helis and Tanks in the broadcast if they are included in the voting layer", + default: true + }, timeFrames: { required: false, description: 'Array of timeframes to override options', @@ -196,8 +201,8 @@ export default class MapVote extends DiscordBasePlugin { this.restorePersistentData = this.restorePersistentData.bind(this) this.endVotingGently = this.endVotingGently.bind(this) - this.broadcast = (msg) => { this.server.rcon.broadcast(msg); }; - this.warn = (steamid, msg) => { this.server.rcon.warn(steamid, msg); }; + this.broadcast = async (msg) => { await this.server.rcon.broadcast(msg); }; + this.warn = async (steamid, msg) => { await this.server.rcon.warn(steamid, msg); }; process.on('uncaughtException', this.savePersistentData); } @@ -726,11 +731,24 @@ export default class MapVote extends DiscordBasePlugin { if (this.nominations.length > 0 && this.votingEnabled) { await this.broadcast(this.options.voteBroadcastMessage); let nominationStrings = []; + for (let choice = 1; choice < this.nominations.length; choice++) { choice = Number(choice); let vLayer = Layers.layers.find(e => e.layerid == this.nominations[ choice ]); - nominationStrings.push(formatChoice(choice, vLayer.map.name + ' ' + vLayer.gamemode + ' ' + this.factionStrings[ choice ], this.tallies[ choice ], (this.options.hideVotesCount || this.firstBroadcast))); + // const allVecs = vLayer.teams[0].vehicles.concat(vLayer.teams[1].vehicles); + const helis = vLayer.teams[ 0 ].numberOfHelicopters + vLayer.teams[ 1 ].numberOfHelicopters + const tanks = vLayer.teams[ 0 ].numberOfTanks + vLayer.teams[ 1 ].numberOfTanks + let assets = []; + if (helis > 0) assets.push('Helis'); + if (tanks > 0) assets.push('Tanks'); + const vehiclesString = this.options.includeMainAssetsInBroadcast ? ' ' + assets.join('-') : ''; + nominationStrings.push(formatChoice(choice, vLayer.map.name + ' ' + vLayer.gamemode + ' ' + this.factionStrings[ choice ] + vehiclesString, this.tallies[ choice ], (this.options.hideVotesCount || this.firstBroadcast))); + if (nominationStrings.length == 3) { + await this.broadcast(nominationStrings.join("\n")); + nominationStrings = []; + } } + if (this.nominations[ 0 ]) nominationStrings.push(formatChoice(0, this.nominations[ 0 ], this.tallies[ 0 ], (this.options.hideVotesCount || this.firstBroadcast))) await this.broadcast(nominationStrings.join("\n")); From 20526e9f6575d6ce372e52a25b89221fc74a27f9 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Sat, 21 Jan 2023 21:13:07 +0100 Subject: [PATCH 6/8] chore: confirm restart succeded --- mapvote.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mapvote.js b/mapvote.js index fb0ca8c..a70aed3 100644 --- a/mapvote.js +++ b/mapvote.js @@ -429,7 +429,7 @@ export default class MapVote extends DiscordBasePlugin { case "restartsqjs": if (!isAdmin) return; await this.warn(steamID, "Saving persistent data.\nTerminating SquadJS process.\nIf managed by a process manager it will automatically restart.") - this.savePersistentData(); + this.savePersistentData(steamID); process.exit(0); return; default: @@ -797,8 +797,17 @@ export default class MapVote extends DiscordBasePlugin { let strMsg = ""; for (let choice in this.nominations) { choice = Number(choice); + + let vLayer = Layers.layers.find(e => e.layerid == this.nominations[ choice ]); + // const allVecs = vLayer.teams[0].vehicles.concat(vLayer.teams[1].vehicles); + // const helis = vLayer?.teams[ 0 ].numberOfHelicopters || 0 + vLayer?.teams[ 1 ].numberOfHelicopters || 0 + // const tanks = vLayer?.teams[ 0 ].numberOfTanks || 0 + vLayer?.teams[ 1 ].numberOfTanks || 0 + // let assets = []; + // if (helis > 0) assets.push('Helis'); + // if (tanks > 0) assets.push('Tanks'); + // const vehiclesString = ' ' + assets.join('-'); // await this.msgDirect(steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ])); - strMsg += (steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ])) + "\n"; + strMsg += (steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ])) + `H:${helis}-T:${tanks}` + "\n"; } strMsg.trim(); if (steamID) this.warn(steamID, strMsg) @@ -873,8 +882,8 @@ export default class MapVote extends DiscordBasePlugin { this.verbose(1, "Error restoring persistent data", e) return } - - for (let k in bkData.server) this.server[ k ] = bkData.server[ k ]; + if (bkData.manualRestartSender && bkData.manualRestartSender != "") this.warn(bkData.manualRestartSender,`SquadJS has completed the restart.\nPersistent data restored.`) + for (let k in bkData.server) this.server[ k ] = bkData.server[ k ]; const maxSecondsDiffierence = 60 if ((new Date() - new Date(bkData.saveDateTime)) / 1000 > maxSecondsDiffierence) return @@ -891,10 +900,9 @@ export default class MapVote extends DiscordBasePlugin { } - savePersistentData() { + savePersistentData(steamID = null) { if (this.options.persistentDataFile == "") return; - const saveDt = { custom: { // layerHistory: this.server.layerHistory.slice(0, this.options.numberRecentMapsToExlude * 2).filter(l => l && l.layerid).map(l => l.layerid), @@ -910,6 +918,7 @@ export default class MapVote extends DiscordBasePlugin { factionStrings: this.factionStrings, firstBroadcast: this.firstBroadcast }, + manualRestartSender: steamID, saveDateTime: new Date() } // this.verbose(1, `Saving persistent data to: ${this.options.persistentDataFile}\n`, saveDt.server.layerHistory) From 5fa1bb25753e457533400834d19d3277f0b6c7cf Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Wed, 25 Jan 2023 22:20:49 +0100 Subject: [PATCH 7/8] fix: layer blacklist + factions blacklist in custom votes --- README.MD | 1 + mapvote.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 95c89ff..56d8eca 100644 --- a/README.MD +++ b/README.MD @@ -231,6 +231,7 @@ Array of timeframes that allows to override options based on local time. See exa "plugin": "MapVote", "enabled": true, "discordClient": "discord", + "entriesAmount": 6, "automaticVoteStart": true, "votingDuration": 0, "minPlayersForVote": 30, diff --git a/mapvote.js b/mapvote.js index a70aed3..3345e9d 100644 --- a/mapvote.js +++ b/mapvote.js @@ -26,6 +26,11 @@ export default class MapVote extends DiscordBasePlugin { description: "command name to use in chat", default: "!vote" }, + entriesAmount: { + required: false, + description: "Amount of entries generated for automatic votes", + default: 6 + }, automaticVoteStart: { required: false, description: "a map vote will automatically start after a new match if set to true", @@ -527,7 +532,7 @@ export default class MapVote extends DiscordBasePlugin { let rnd_layers = []; const sanitizedLayers = Layers.layers.filter((l) => l.layerid && l.map); - const maxOptions = this.options.showRerollOption ? 5 : 6; + const maxOptions = this.options.showRerollOption ? 20 : 21; const recentlyPlayedMaps = this.objArrToValArr(this.server.layerHistory.slice(0, this.options.numberRecentMapsToExlude), "layer", "map", "name"); this.verbose(1, "Recently played maps: " + recentlyPlayedMaps.join(', '));//recentlyPlayedMaps.filter((l) => l && l.map && l.map.name).map((l) => l.map.name).join(', ')) @@ -576,6 +581,10 @@ export default class MapVote extends DiscordBasePlugin { && (l.gamemode.toLowerCase().startsWith(cls[ 1 ]) || (!cls[ 1 ] && [ 'RAAS', 'AAS', 'INVASION' ].includes(l.gamemode.toUpperCase()))) && (!cls[ 2 ] || l.version.toLowerCase().startsWith("v" + cls[ 2 ].replace(/v/gi, ''))) && !(this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f))) + && (cls[ 3 ] || !( + this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid)) + || this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f)) + )) )); let l, maxtries = 10; do l = randomElement(fLayers); while ((rnd_layers.filter(lf => lf.map.name == l.map.name).length > (this.options.allowedSameMapEntries - 1)) && --maxtries >= 0) @@ -882,8 +891,14 @@ export default class MapVote extends DiscordBasePlugin { this.verbose(1, "Error restoring persistent data", e) return } - if (bkData.manualRestartSender && bkData.manualRestartSender != "") this.warn(bkData.manualRestartSender,`SquadJS has completed the restart.\nPersistent data restored.`) - for (let k in bkData.server) this.server[ k ] = bkData.server[ k ]; + if (bkData.manualRestartSender && bkData.manualRestartSender != "") { + (async () => { + await this.warn(bkData.manualRestartSender, `SquadJS has completed the restart.\nPersistent data restored.`) + this.verbose(1, `Restart confirmation sent to SteamID: "${bkData.manualRestartSender}"`) + })() + } + + for (let k in bkData.server) this.server[ k ] = bkData.server[ k ]; const maxSecondsDiffierence = 60 if ((new Date() - new Date(bkData.saveDateTime)) / 1000 > maxSecondsDiffierence) return From 7843bf50b8a441e490be4b382135bc4643bae888 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Thu, 26 Jan 2023 00:21:34 +0100 Subject: [PATCH 8/8] fixes + doc update --- README.MD | 17 ++++++++++++++++- mapvote.js | 29 ++++++++++++++++++----------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/README.MD b/README.MD index 56d8eca..57b7ff6 100644 --- a/README.MD +++ b/README.MD @@ -36,6 +36,13 @@ The command name to use in chat. ``` !vote ``` +#### entriesAmount +###### Description +Amount of entries generated for automatic votes. +###### Default +```json +6 +``` #### automaticVoteStart ###### Description A map vote will automatically start after a new match if set to true. @@ -148,6 +155,13 @@ vote option to restart the vote with random entries. ```json false ``` +#### showRerollOptionInCustomVotes +###### Description +Enables/disables the reroll option only in custom votes. showRerollOption must be set to true. +###### Default +```json +false +``` #### voteBroadcastMessage ###### Description Message that is sent as broadcast to announce a vote. @@ -246,7 +260,8 @@ Array of timeframes that allows to override options based on local time. See exa "factionsBlacklist": [ "CAF", "INS" ], "minRaasEntries": 2, "hideVotesCount": false, - "showRerollOption": false, + "showRerollOption": true, + "showRerollOptionInCustomVotes": false, "voteBroadcastMessage": "✯ MAPVOTE ✯\nVote for the next map by writing in chat the corresponding number!", "voteWinnerBroadcastMessage": "✯ MAPVOTE ✯\nThe winning layer is\n\n", "showWinnerBroadcastMessage": true, diff --git a/mapvote.js b/mapvote.js index 3345e9d..ca3184e 100644 --- a/mapvote.js +++ b/mapvote.js @@ -115,6 +115,11 @@ export default class MapVote extends DiscordBasePlugin { description: 'vote option to restart the vote with random entries', default: false }, + showRerollOptionInCustomVotes: { + required: false, + description: 'enables/disables the reroll option only in custom votes. showRerollOption must be set to true', + default: false + }, voteBroadcastMessage: { required: false, description: 'Message that is sent as broadcast to announce a vote', @@ -533,11 +538,13 @@ export default class MapVote extends DiscordBasePlugin { const sanitizedLayers = Layers.layers.filter((l) => l.layerid && l.map); const maxOptions = this.options.showRerollOption ? 20 : 21; + const optionAmount = Math.min(maxOptions, this.options.entriesAmount); const recentlyPlayedMaps = this.objArrToValArr(this.server.layerHistory.slice(0, this.options.numberRecentMapsToExlude), "layer", "map", "name"); this.verbose(1, "Recently played maps: " + recentlyPlayedMaps.join(', '));//recentlyPlayedMaps.filter((l) => l && l.map && l.map.name).map((l) => l.map.name).join(', ')) - if (!cmdLayers || cmdLayers.length == 0) { + const isRandomVote = !cmdLayers || cmdLayers.length == 0; + if (isRandomVote) { const all_layers = sanitizedLayers.filter((l) => this.options.gamemodeWhitelist.includes(l.gamemode.toUpperCase()) && ![ this.server.currentLayer ? this.server.currentLayer.map.name : null, ...recentlyPlayedMaps ].includes(l.map.name) && @@ -551,8 +558,8 @@ export default class MapVote extends DiscordBasePlugin { ) && !(this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f))) ); - for (let i = 1; i <= maxOptions; i++) { - const needMoreRAAS = !bypassRaasFilter && rnd_layers.filter((l) => l.gamemode === 'RAAS').length < this.options.minRaasEntries; + for (let i = 1; i <= optionAmount; i++) { + const needMoreRAAS = !bypassRaasFilter && rnd_layers.filter((l) => l.gamemode.toUpperCase() === 'RAAS').length < this.options.minRaasEntries; let l, maxtries = 20; do l = randomElement(needMoreRAAS ? all_layers.filter((l) => l.gamemode.toLowerCase() == "raas") : all_layers); while ((rnd_layers.find(lf => lf.layerid == l.layerid) || rnd_layers.filter(lf => lf.map.name == l.map.name).length > (this.options.allowedSameMapEntries - 1)) && --maxtries >= 0) if (maxtries > 0 && l) { @@ -570,7 +577,7 @@ export default class MapVote extends DiscordBasePlugin { return; } } else { - if (cmdLayers.length == 1) while (cmdLayers.length < maxOptions) cmdLayers.push(cmdLayers[ 0 ]) + if (cmdLayers.length == 1) while (cmdLayers.length < optionAmount) cmdLayers.push(cmdLayers[ 0 ]) if (cmdLayers.length <= maxOptions) { let i = 1; @@ -578,7 +585,7 @@ export default class MapVote extends DiscordBasePlugin { const cls = cl.split('_'); const fLayers = sanitizedLayers.filter((l) => ( (cls[ 0 ] == "*" || l.layerid.toLowerCase().startsWith(cls[ 0 ])) - && (l.gamemode.toLowerCase().startsWith(cls[ 1 ]) || (!cls[ 1 ] && [ 'RAAS', 'AAS', 'INVASION' ].includes(l.gamemode.toUpperCase()))) + && (l.gamemode.toLowerCase().startsWith(cls[ 1 ]) || (!cls[ 1 ] && this.options.gamemodeWhitelist.includes(l.gamemode.toUpperCase()))) && (!cls[ 2 ] || l.version.toLowerCase().startsWith("v" + cls[ 2 ].replace(/v/gi, ''))) && !(this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f))) && (cls[ 3 ] || !( @@ -603,12 +610,12 @@ export default class MapVote extends DiscordBasePlugin { } } - if (this.options.showRerollOption) { - if (this.nominations.length > 5) { - this.nominations.splice(6, 1); - this.tallies.splice(6, 1); - this.factionStrings.splice(6, 1); - } + if (this.options.showRerollOption && (isRandomVote || this.options.showRerollOptionInCustomVotes)) { + // if (this.nominations.length > 5) { + // this.nominations.splice(6, 1); + // this.tallies.splice(6, 1); + // this.factionStrings.splice(6, 1); + // } this.newVoteOptions.steamid = steamid; this.newVoteOptions.bypassRaasFilter = bypassRaasFilter;