mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
discord unregressions
This commit is contained in:
@@ -50,6 +50,7 @@ function isCharging(sensors) {
|
||||
function buildRoverStatusSnapshot(record) {
|
||||
if (!record) return null;
|
||||
const sensors = record.lastSensor?.decoded || record.lastSensor?.sensors || null;
|
||||
const oiMode = String(sensors?.oiMode?.label || 'unknown').toLowerCase();
|
||||
return {
|
||||
id: record.id,
|
||||
name: record.meta?.name || record.id,
|
||||
@@ -61,7 +62,7 @@ function buildRoverStatusSnapshot(record) {
|
||||
voltageMv: sensors?.voltageMv ?? null,
|
||||
currentMa: sensors?.currentMa ?? null,
|
||||
batteryState: record.batteryState,
|
||||
oiMode: sensors?.oiMode?.label || 'unknown',
|
||||
oiMode,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,16 +86,16 @@ function buildBatteryStatusEmbed({ color = 0x2196f3, records = [], includeOi = t
|
||||
].join(' ');
|
||||
|
||||
const lines = [
|
||||
`Dock: ${dockLabel}`,
|
||||
`Charging: ${chargingLabel}`,
|
||||
`Battery: ${formatChargeState(snapshot.batteryState)}`,
|
||||
`Voltage: ${formatVoltage(snapshot.voltageMv)}`,
|
||||
`Current: ${formatCurrent(snapshot.currentMa)}`,
|
||||
`${formatDockEmoji(snapshot.docked)} Dock: ${dockLabel}`,
|
||||
`${formatChargeEmoji(snapshot.charging)} Charging: ${chargingLabel}`,
|
||||
`${formatBatteryEmoji(snapshot.batteryState)} Battery: ${formatChargeState(snapshot.batteryState)}`,
|
||||
`🔌 Voltage: ${formatVoltage(snapshot.voltageMv)}`,
|
||||
`📈 Current: ${formatCurrent(snapshot.currentMa)}`,
|
||||
];
|
||||
if (includeOi) {
|
||||
lines.push(`OI: ${snapshot.oiMode} ${formatOiEmoji(snapshot.oiMode)}`);
|
||||
lines.push(`${formatOiEmoji(snapshot.oiMode)} OI mode: ${snapshot.oiMode}`);
|
||||
}
|
||||
lines.push(`Lock: ${lockLabel}`);
|
||||
lines.push(`${formatLockEmoji(snapshot.locked)} Lock: ${lockLabel}`);
|
||||
|
||||
embed.addFields({
|
||||
name: `${header} ${snapshot.name}`,
|
||||
|
||||
@@ -90,8 +90,19 @@ function createDmModerationHandlers(deps) {
|
||||
}
|
||||
const linked = getRequestByMessageId(reaction.message?.id);
|
||||
if (!linked?.request || linked.request.status !== 'pending') return;
|
||||
if (emoji === APPROVE) approveRequest(linked.request.id, user.id);
|
||||
else denyRequest(linked.request.id, user.id);
|
||||
if (emoji === APPROVE) {
|
||||
approveRequest(linked.request.id, user.id);
|
||||
await reaction.message.reply({
|
||||
content: `✅ Verification request \`${linked.request.id}\` approved by ${sanitizeMentions(user.username || user.tag || user.id)}.`,
|
||||
allowedMentions: { parse: [] },
|
||||
});
|
||||
} else {
|
||||
denyRequest(linked.request.id, user.id);
|
||||
await reaction.message.reply({
|
||||
content: `❌ Verification request \`${linked.request.id}\` denied by ${sanitizeMentions(user.username || user.tag || user.id)}.`,
|
||||
allowedMentions: { parse: [] },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePrivateAccessReaction(reaction, user) {
|
||||
@@ -103,8 +114,19 @@ function createDmModerationHandlers(deps) {
|
||||
}
|
||||
const linked = getPrivateAccessRequestByMessageId(reaction.message?.id);
|
||||
if (!linked?.request || linked.request.status !== 'pending') return;
|
||||
if (emoji === APPROVE) approvePrivateAccessRequest(linked.request.id, user.id);
|
||||
else denyPrivateAccessRequest(linked.request.id, user.id);
|
||||
if (emoji === APPROVE) {
|
||||
approvePrivateAccessRequest(linked.request.id, user.id);
|
||||
await reaction.message.reply({
|
||||
content: `✅ Private access request \`${linked.request.id}\` approved by ${sanitizeMentions(user.username || user.tag || user.id)}.`,
|
||||
allowedMentions: { parse: [] },
|
||||
});
|
||||
} else {
|
||||
denyPrivateAccessRequest(linked.request.id, user.id);
|
||||
await reaction.message.reply({
|
||||
content: `❌ Private access request \`${linked.request.id}\` denied by ${sanitizeMentions(user.username || user.tag || user.id)}.`,
|
||||
allowedMentions: { parse: [] },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user