updates log surroundings
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s
This commit is contained in:
parent
690760c6b8
commit
eba4ab70c8
1 changed files with 13 additions and 12 deletions
|
|
@ -63,19 +63,20 @@ module.exports = async function logSurroundings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found.length > 0) {
|
const newTypes = Array.from(observedTypes);
|
||||||
const summary = found
|
if (newTypes.length > 0) {
|
||||||
.map(pos => bot.blockAt(pos)?.name)
|
const counts = {};
|
||||||
.filter(Boolean)
|
for (const pos of found) {
|
||||||
.reduce((acc, name) => {
|
const name = bot.blockAt(pos)?.name;
|
||||||
acc[name] = (acc[name] || 0) + 1;
|
if (newTypes.includes(name)) {
|
||||||
return acc;
|
counts[name] = (counts[name] || 0) + 1;
|
||||||
}, {});
|
}
|
||||||
|
}
|
||||||
const summaryMsg = Object.entries(summary)
|
|
||||||
|
const summaryMsg = Object.entries(counts)
|
||||||
.map(([name, count]) => `${count} ${name.replace(/_/g, ' ')}`)
|
.map(([name, count]) => `${count} ${name.replace(/_/g, ' ')}`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
bot.chat(`I noticed: ${summaryMsg}`);
|
if (summaryMsg) bot.chat(`I noticed: ${summaryMsg}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Loading…
Reference in a new issue