mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
community goal? never jnew her
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
// Discord Goal Command
|
||||
// Purpose: Handles community goal view/update/clear operations.
|
||||
// Purpose: Handles global objective view/update/clear operations.
|
||||
// Scope: Allows read by all and write by admins.
|
||||
function createGoalCommand({ getCommunityGoal, setCommunityGoal, clearCommunityGoal, isAdminUser, sanitizeMentions }) {
|
||||
function createGoalCommand({ getGlobalObjective, setGlobalObjective, clearGlobalObjective, isAdminUser, sanitizeMentions }) {
|
||||
return async function handleGoalCommand(message, tokens) {
|
||||
const query = tokens.join(' ').trim();
|
||||
const lower = query.toLowerCase();
|
||||
if (!query) {
|
||||
const goal = getCommunityGoal();
|
||||
await message.reply({ content: goal?.text ? `Community goal: ${sanitizeMentions(goal.text)}` : 'No community goal set.', allowedMentions: { parse: [], repliedUser: false } });
|
||||
const goal = getGlobalObjective();
|
||||
await message.reply({ content: goal?.text ? `Global objective: ${sanitizeMentions(goal.text)}` : 'No global objective set.', allowedMentions: { parse: [], repliedUser: false } });
|
||||
return;
|
||||
}
|
||||
if (!isAdminUser(message.author.id)) {
|
||||
await message.reply({ content: 'Only admins can update the community goal.', allowedMentions: { parse: [], repliedUser: false } });
|
||||
await message.reply({ content: 'Only admins can update the global objective.', allowedMentions: { parse: [], repliedUser: false } });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (lower === 'clear') {
|
||||
clearCommunityGoal({ by: message.author?.id || null });
|
||||
await message.reply({ content: 'Community goal cleared.', allowedMentions: { parse: [], repliedUser: false } });
|
||||
clearGlobalObjective({ by: message.author?.id || null });
|
||||
await message.reply({ content: 'Global objective cleared.', allowedMentions: { parse: [], repliedUser: false } });
|
||||
} else {
|
||||
setCommunityGoal(query, { by: message.author?.id || null });
|
||||
await message.reply({ content: sanitizeMentions(`Community goal set: ${query}`), allowedMentions: { parse: [], repliedUser: false } });
|
||||
setGlobalObjective(query, { by: message.author?.id || null });
|
||||
await message.reply({ content: sanitizeMentions(`Global objective set: ${query}`), allowedMentions: { parse: [], repliedUser: false } });
|
||||
}
|
||||
} catch (err) {
|
||||
await message.reply({ content: sanitizeMentions(`Failed to update goal: ${err.message}`), allowedMentions: { parse: [], repliedUser: false } });
|
||||
|
||||
@@ -15,7 +15,7 @@ function formatHelp() {
|
||||
'`rs unlock <id>` — unlock a rover',
|
||||
'`rs mode <open|turns|admin|lockdown>` — change server mode',
|
||||
'`rs reason [text|clear]` — show or set admin mode reason',
|
||||
'`rs goal [text|clear]` — show or set community goal',
|
||||
'`rs goal [text|clear]` — show or set global objective',
|
||||
'`rs verify list|remove ...` — manage verified users',
|
||||
'`rs deter list|ban|unban ...` — manage deterred users',
|
||||
'`ts` — show time status',
|
||||
|
||||
@@ -16,7 +16,7 @@ const { sendExternalMessage, sendExternalTyping } = require('../chatService');
|
||||
const { buildReplayVideo, getReplaySources, getDefaultDiscordSources, validateSources, tryTriggerReplay } = require('../replayEngineV2');
|
||||
const { getActiveDrivers } = require('../turnService');
|
||||
const { getNickname } = require('../nicknameService');
|
||||
const { getCommunityGoal, setCommunityGoal, clearCommunityGoal } = require('../communityGoalService');
|
||||
const { getGlobalObjective, setGlobalObjective, clearGlobalObjective } = require('../globalObjectiveService');
|
||||
const { getAdminReason, setAdminReason, clearAdminReason } = require('../adminReasonService');
|
||||
const {
|
||||
getGuildConfig,
|
||||
@@ -108,7 +108,7 @@ const presence = createPresenceManager({
|
||||
client,
|
||||
logger,
|
||||
getMode,
|
||||
getCommunityGoal,
|
||||
getGlobalObjective,
|
||||
countReady,
|
||||
});
|
||||
|
||||
@@ -129,9 +129,9 @@ const commands = createCommandHandlers({
|
||||
getDefaultDiscordSources,
|
||||
validateSources,
|
||||
tryTriggerReplay,
|
||||
getCommunityGoal,
|
||||
setCommunityGoal,
|
||||
clearCommunityGoal,
|
||||
getGlobalObjective,
|
||||
setGlobalObjective,
|
||||
clearGlobalObjective,
|
||||
getAdminReason,
|
||||
setAdminReason,
|
||||
clearAdminReason,
|
||||
|
||||
@@ -98,8 +98,8 @@ function createBusEventHandler(deps) {
|
||||
}
|
||||
schedulePresenceRotation();
|
||||
break;
|
||||
case 'communityGoal.updated':
|
||||
announce({ channelId: channels.announcements, content: payload?.text ? `Community goal: ${payload.text}` : 'Community goal cleared.', color: 0x8bc34a, title: 'Community Goal', description: payload?.text || 'Community goal cleared.' });
|
||||
case 'globalObjective.updated':
|
||||
announce({ channelId: channels.announcements, content: payload?.text ? `Global objective: ${payload.text}` : 'Global objective cleared.', color: 0x8bc34a, title: 'Global Objective', description: payload?.text || 'Global objective cleared.' });
|
||||
schedulePresenceRotation();
|
||||
break;
|
||||
case 'rover.online':
|
||||
|
||||
@@ -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