From 9f6fea2423f532701fb1b427cfb7863625cc6b50 Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 29 Apr 2021 08:24:51 +0500 Subject: [PATCH] feat(command): :loud_sound: add system (non-chat) messages to console log This includes anything that doesn't return a `.text`. Such as an `extra`, `translate` or other `json` formatted message. Ex: - afk - errors - player leave and joins --- lib/plugins/command.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/plugins/command.js b/lib/plugins/command.js index 6bf07eb..770e081 100644 --- a/lib/plugins/command.js +++ b/lib/plugins/command.js @@ -56,6 +56,23 @@ const events = { }, 15 * 60 * 1000, bot, cfg); } } + , message: systemMessage +} + +function systemMessage(...args) { + if (args[0]?.text) return + const metadata = (args[0]?.extra || args[0]?.with)?.map(v => v.text) + console.log( + "cmd msg:", + args[0]?.text || args[0]?.translate, + args[0]?.extra?.length || args[0]?.with?.length || Object.keys(args[0]?.json).length - 1, + metadata.length > 0 && metadata || args[0], + args.slice(1) + ) +} + +function _clientSystemMessage(...args) { + console.log("cmd msg:", args[0]?.message, args[0]?.extra?.length, args[0]?.extra, args[0], args.slice(1)) } const events_registered = []