Skip to content

Commit

Permalink
Undo special timing rule for the first election cycle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 4, 2024
1 parent 7cb51f8 commit cfbd047
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions presidential-election.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ const channelId = '1299963218265116753';
// The cycle and the phases are tied to the Thursdays at 18:00 UTC because
// that is the moment of the "wipe" in Rust.
function CalculateCurrentPhaseOfElectionCycle() {
if (moment().isBefore(moment('2024-11-04 18:00:00'))) {
// TODO: remove this after the first election cycle.
return 'election';
}
const weekOfMonth = RustCalendar.CalculateCurrentWeekOfTheMonth();
const weeksThisMonth = RustCalendar.CalculateHowManyThursdaysThisMonth();
if (weeksThisMonth === 4) {
Expand Down Expand Up @@ -70,7 +66,7 @@ async function UpdatePresidencyPhase() {
return;
}
presidencyPhaseUpdated = true;
return CountVotesAndAwardPresidency();
//await CountVotesAndAwardPresidency();
}

// Handle routine updates during the vacant phase of the cycle.
Expand Down Expand Up @@ -150,7 +146,7 @@ function CalculateUnixTimestampOfElectionEndForThisMonth() {
const thursdays = RustCalendar.CalculateArrayOfAllThursdayEpochsThisMonth();
const n = thursdays.length;
// TODO: remove the 4 extra days after the first election cycle.
return thursdays[n - 1] - (86400 * 24);
return thursdays[n - 1];
}

// Start the election phase of the cycle. Print the ballot and wire up all the buttons for voting.
Expand Down Expand Up @@ -201,6 +197,11 @@ async function CheckReactionForPresidentialVote(reaction, discordUser, notifyVot
if (reaction.message.channelId !== channelId) {
return;
}
const phase = CalculateCurrentPhaseOfElectionCycle();
if (phase !== 'election') {
// Ignore votes received outside the designated election phase.
return;
}
const candidate = GetCandidateByMessageId(reaction.message.id);
if (!candidate) {
console.log('Vote detected but could not determine for which candidate.');
Expand Down

0 comments on commit cfbd047

Please sign in to comment.