updates log surroundings
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s

This commit is contained in:
roberts 2025-05-10 19:16:03 -05:00
parent 690760c6b8
commit eba4ab70c8

View file

@ -63,19 +63,20 @@ module.exports = async function logSurroundings() {
}
}
if (found.length > 0) {
const summary = found
.map(pos => bot.blockAt(pos)?.name)
.filter(Boolean)
.reduce((acc, name) => {
acc[name] = (acc[name] || 0) + 1;
return acc;
}, {});
const newTypes = Array.from(observedTypes);
if (newTypes.length > 0) {
const counts = {};
for (const pos of found) {
const name = bot.blockAt(pos)?.name;
if (newTypes.includes(name)) {
counts[name] = (counts[name] || 0) + 1;
}
}
const summaryMsg = Object.entries(summary)
const summaryMsg = Object.entries(counts)
.map(([name, count]) => `${count} ${name.replace(/_/g, ' ')}`)
.join(', ');
bot.chat(`I noticed: ${summaryMsg}`);
if (summaryMsg) bot.chat(`I noticed: ${summaryMsg}`);
}
};