mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-24 00:13:52 -06:00
fix: vote end warns
This commit is contained in:
parent
7843bf50b8
commit
b62be4d978
102
mapvote.js
102
mapvote.js
@ -372,7 +372,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
await this.warn(steamID, "There is no vote running right now");
|
await this.warn(steamID, "There is no vote running right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.directMsgNominations(steamID);
|
await this.directMsgNominations(steamID);
|
||||||
return;
|
return;
|
||||||
case "start": //starts the vote again if it was canceled
|
case "start": //starts the vote again if it was canceled
|
||||||
if (!isAdmin) return;
|
if (!isAdmin) return;
|
||||||
@ -405,8 +405,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
await this.warn(steamID, "There is no vote running right now");
|
await this.warn(steamID, "There is no vote running right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.endVotingGently();
|
this.endVotingGently(steamID);
|
||||||
await this.warn(steamID, "Ending current vote");
|
|
||||||
return;
|
return;
|
||||||
case "cancelauto": //cancels the current vote and wont set next map to current winnner
|
case "cancelauto": //cancels the current vote and wont set next map to current winnner
|
||||||
if (!isAdmin) return;
|
if (!isAdmin) return;
|
||||||
@ -670,55 +669,64 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
this.broadcastIntervalTask = setInterval(this.broadcastNominations, toMils(this.options.voteBroadcastInterval));
|
this.broadcastIntervalTask = setInterval(this.broadcastNominations, toMils(this.options.voteBroadcastInterval));
|
||||||
}
|
}
|
||||||
|
|
||||||
async endVotingGently() {
|
async endVotingGently(steamID = null) {
|
||||||
this.endVoting();
|
this.endVoting();
|
||||||
|
|
||||||
|
if (steamID) await this.warn(steamID, "Voting terminated!");
|
||||||
|
|
||||||
const winnerLayer = Layers.layers.find((l) => l.layerid == this.updateNextMap());
|
const winnerLayer = Layers.layers.find((l) => l.layerid == this.updateNextMap());
|
||||||
const fancyWinner = this.formatFancyLayer(winnerLayer);
|
const fancyWinner = this.formatFancyLayer(winnerLayer);
|
||||||
if (this.showWinnerBroadcastMessage) await this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner);
|
|
||||||
|
|
||||||
if (!this.options.logToDiscord) return
|
console.log("winning layer", winnerLayer, fancyWinner)
|
||||||
return await this.sendDiscordMessage({
|
|
||||||
embed: {
|
if (this.showWinnerBroadcastMessage) this.broadcast(this.options.voteWinnerBroadcastMessage + fancyWinner);
|
||||||
title: `Vote winner: ${fancyWinner}`,
|
|
||||||
color: 16761867,
|
if (this.options.logToDiscord) {
|
||||||
fields: [
|
await this.sendDiscordMessage({
|
||||||
{
|
embed: {
|
||||||
name: 'Map',
|
title: `Vote winner: ${fancyWinner}`,
|
||||||
value: winnerLayer.map.name,
|
color: 16761867,
|
||||||
inline: true
|
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`
|
||||||
},
|
},
|
||||||
{
|
|
||||||
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()
|
||||||
timestamp: (new Date()).toISOString()
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
endVoting() {
|
endVoting() {
|
||||||
@ -823,7 +831,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
// if (tanks > 0) assets.push('Tanks');
|
// if (tanks > 0) assets.push('Tanks');
|
||||||
// const vehiclesString = ' ' + assets.join('-');
|
// const vehiclesString = ' ' + assets.join('-');
|
||||||
// await this.msgDirect(steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ]));
|
// await this.msgDirect(steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ]));
|
||||||
strMsg += (steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ])) + `H:${helis}-T:${tanks}` + "\n";
|
strMsg += (steamID, formatChoice(choice, this.nominations[ choice ], this.tallies[ choice ])) + "\n";
|
||||||
}
|
}
|
||||||
strMsg.trim();
|
strMsg.trim();
|
||||||
if (steamID) this.warn(steamID, strMsg)
|
if (steamID) this.warn(steamID, strMsg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user