Skip to content

Commit

Permalink
Update mayorCommand.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Killermaschine88 authored Sep 5, 2024
1 parent 7d6a858 commit ff55f43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/minecraft/commands/mayorCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class MayorCommand extends minecraftCommand {
this.send(
`/gc [MAYOR] ${data.mayor.name} is the current mayor of Skyblock! Perks: ${data.mayor.perks
.map((perk) => perk.name)
.join(", ")}, ${data.mayor.minister.perk[0].name}`,
.join(", ")}, Minister Perk: ${data.mayor.minister.perk.name}`,
);
await delay(500);
if (data.current.candidates.length > 0) {
const currentLeader = data.current.candidates.sort((a, b) => (b.votes || 0) - (a.votes || 0))[0];
if (data.mayor.election.candidates.length > 0) {
const currentLeader = data.mayor.election.candidates.sort((a, b) => (b.votes || 0) - (a.votes || 0))[0];
if (!currentLeader) return;
const totalVotes = data.current.candidates.reduce((total, candidate) => total + (candidate.votes || 0), 0);
const totalVotes = data.mayor.election.candidates.reduce((total, candidate) => total + (candidate.votes || 0), 0);
const percentage = ((currentLeader.votes || 0) / totalVotes) * 100;
this.send(`/gc [MAYOR] Current Election: ${currentLeader.name} has ${percentage.toFixed(2)}% of the votes.`);
}
Expand Down

0 comments on commit ff55f43

Please sign in to comment.