From 050e2b3bd991dd46fec1f2b93f49efe83d4b0f2f Mon Sep 17 00:00:00 2001 From: jay Date: Fri, 7 May 2021 12:53:24 +0500 Subject: [PATCH] feat(informer): :children_crossing: add sub-command for module level quiet --- lib/plugins/informer.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/plugins/informer.js b/lib/plugins/informer.js index 977ab83..c077f55 100644 --- a/lib/plugins/informer.js +++ b/lib/plugins/informer.js @@ -18,12 +18,12 @@ function block(pos) { const block = pos ? bot.blockAt(v(pos)) : bot.blockAtCursor() console.log(block, block && block.getProperties()) if (!block) { - cfg.quiet || bot.chat("empty block") + quiet || bot.chat("empty block") return block } let info = [block.type, block.name] if (block.metadata) info.push(Object.entries(block.getProperties())) - cfg.quiet || bot.chat(info.join(": ")) + quiet || bot.chat(info.join(": ")) } function item( @@ -35,7 +35,7 @@ function item( entity.heldItem console.log(item) if (!item) { - cfg.quiet || bot.chat("no item") + quiet || bot.chat("no item") return item } let info = [item.type, item.name] @@ -43,7 +43,7 @@ function item( if (item.nbt) { info.push(compound_value(item.nbt)) } - cfg.quiet || bot.chat(info.join("; ")) + quiet || bot.chat(info.join("; ")) function compound_value(obj) { if (typeof obj.value == "object") { return compound_value(obj.value) @@ -68,13 +68,13 @@ function entity(name) { }) : entity console.log(entity) if (!entity) { - cfg.quiet || bot.chat("no entity") + quiet || bot.chat("no entity") return entity } let info = [entity.type, entity.username || entity.name] // TODO various info depending on the type of entity; player, villager, etc if (entity.metadata) info.push("len: " + entity.metadata.length) - cfg.quiet || bot.chat(info.join("; ")) + quiet || bot.chat(info.join("; ")) return entity } @@ -94,6 +94,10 @@ function command(message_parts, player) { break; case 1: switch (message_parts[0]) { + case "quiet": + cfg.info.quiet = quiet = !quiet; + quiet || bot.chat(`info: ${quiet ? "" : "not "}being quiet`); + break; case "i": case "item": item()