community goal? never jnew her

This commit is contained in:
legop3
2026-05-01 01:18:21 -04:00
parent eefe434607
commit b491d91ec5
17 changed files with 89 additions and 80 deletions
@@ -1,12 +1,12 @@
// Discord Presence Module
// Purpose: Owns rotating Discord presence text derived from rover readiness, mode, and community goals.
// Purpose: Owns rotating Discord presence text derived from rover readiness, mode, and global objectives.
// Scope: Handles presence update scheduling/state and exposes start/recompute controls for orchestration.
const { ActivityType } = require('discord.js');
function createPresenceManager({ client, logger, getMode, getCommunityGoal, countReady }) {
function createPresenceManager({ client, logger, getMode, getGlobalObjective, countReady }) {
const PRESENCE_ROTATE_MS = 20000;
let presenceInterval = null;
let presenceShowGoal = false;
let presenceShowObjective = false;
function truncatePresenceText(text, maxLength) {
if (!text) return '';
@@ -18,11 +18,11 @@ function createPresenceManager({ client, logger, getMode, getCommunityGoal, coun
function buildPresenceName() {
const { ready, total } = countReady();
const mode = getMode();
const goal = getCommunityGoal();
const goalText = goal?.text ? String(goal.text).trim() : '';
if (presenceShowGoal && goalText) {
const trimmed = truncatePresenceText(goalText, 110);
return `Goal: ${trimmed}`;
const objective = getGlobalObjective();
const objectiveText = objective?.text ? String(objective.text).trim() : '';
if (presenceShowObjective && objectiveText) {
const trimmed = truncatePresenceText(objectiveText, 110);
return `Objective: ${trimmed}`;
}
return `${mode} · ${ready}/${total} Rovers Ready`;
}
@@ -44,16 +44,16 @@ function createPresenceManager({ client, logger, getMode, getCommunityGoal, coun
clearInterval(presenceInterval);
presenceInterval = null;
}
const goal = getCommunityGoal();
if (!goal?.text) {
presenceShowGoal = false;
const objective = getGlobalObjective();
if (!objective?.text) {
presenceShowObjective = false;
updatePresence();
return;
}
presenceShowGoal = false;
presenceShowObjective = false;
updatePresence();
presenceInterval = setInterval(() => {
presenceShowGoal = !presenceShowGoal;
presenceShowObjective = !presenceShowObjective;
updatePresence();
}, PRESENCE_ROTATE_MS);
}