fix: vote end broadcast

This commit is contained in:
Davide Fantino 2023-03-01 00:36:38 +01:00
parent bf2d7b093b
commit bbb14936e9

View File

@ -217,6 +217,7 @@ export default class MapVote extends DiscordBasePlugin {
this.restorePersistentData = this.restorePersistentData.bind(this); this.restorePersistentData = this.restorePersistentData.bind(this);
this.endVotingGently = this.endVotingGently.bind(this); this.endVotingGently = this.endVotingGently.bind(this);
this.formatChoice = this.formatChoice.bind(this); this.formatChoice = this.formatChoice.bind(this);
this.updateNextMap = this.updateNextMap.bind(this);
this.broadcast = async (msg) => { await this.server.rcon.broadcast(msg); }; this.broadcast = async (msg) => { await this.server.rcon.broadcast(msg); };
this.warn = async (steamid, msg) => { await this.server.rcon.warn(steamid, msg); }; this.warn = async (steamid, msg) => { await this.server.rcon.warn(steamid, msg); };
@ -686,12 +687,15 @@ export default class MapVote extends DiscordBasePlugin {
if (steamID) await this.warn(steamID, "Voting terminated!"); if (steamID) await this.warn(steamID, "Voting terminated!");
const winnerLayer = Layers.layers.find((l) => l.layerid == this.updateNextMap()); const winningLayerId = this.updateNextMap();
if (!winningLayerId) return;
const winnerLayer = Layers.layers.find((l) => l.layerid == winningLayerId);
const fancyWinner = this.formatFancyLayer(winnerLayer); const fancyWinner = this.formatFancyLayer(winnerLayer);
console.log("winning layer", winnerLayer, fancyWinner) // this.verbose(1, "Winning layer", winnerLayer, fancyWinner)
if (this.showWinnerBroadcastMessage) this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner); if (this.options.showWinnerBroadcastMessage) this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner);
if (this.options.logToDiscord) { if (this.options.logToDiscord) {
await this.sendDiscordMessage({ await this.sendDiscordMessage({