mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-17 01:50:47 -04:00
community goal? never jnew her
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user