mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
add previous message to console and commands plugin
This commit is contained in:
parent
69fa38a808
commit
5c27a494c6
2 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue