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 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}`);
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue