From 5c27a494c6520922af9eac717c6ed25976cb5ef7 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Tue, 6 Dec 2022 19:04:36 +0700 Subject: [PATCH] add previous message to console and commands plugin --- plugins/commands.js | 8 ++++++++ plugins/console.js | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/plugins/commands.js b/plugins/commands.js index bdaef14..3c3f6a3 100644 --- a/plugins/commands.js +++ b/plugins/commands.js @@ -61,9 +61,17 @@ function inject (bot, dcclient, config) { bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector) } } + let previousMessage = { username: '', message: '' } bot.on('message', async (_username, _message, _sender) => { // try catch cuz TypeError: Cannot read properties of undefined (reading 'replace') try { + if ( + previousMessage.username === _username && + previousMessage.message === _message + ) return + + previousMessage = { username: _username, message: _message } + const usernameraw = _username.replace(/ยง.?/g, '') const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw] let username diff --git a/plugins/console.js b/plugins/console.js index 5c139f2..c67bf22 100644 --- a/plugins/console.js +++ b/plugins/console.js @@ -31,8 +31,12 @@ function inject (bot, _dcclient, config, rl) { log(prefix('&cERROR', typeof error === 'string' ? error : error.stack)) } + // previous message is op feature to have in console :) + let previousMessage = '' bot.on('parsed_chat', (message) => { if (!bot.options.logging) return + if (previousMessage === message.toString()) return + previousMessage = message.toString() bot.console.log(message.toAnsi()) })