diff --git a/bot/lib/log-surroundings.js b/bot/lib/log-surroundings.js index 2776b8c..ba84e7f 100644 --- a/bot/lib/log-surroundings.js +++ b/bot/lib/log-surroundings.js @@ -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 summaryMsg = Object.entries(summary) + 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(counts) .map(([name, count]) => `${count} ${name.replace(/_/g, ' ')}`) .join(', '); - - bot.chat(`I noticed: ${summaryMsg}`); + + if (summaryMsg) bot.chat(`I noticed: ${summaryMsg}`); } }; \ No newline at end of file