remove + add

This commit is contained in:
ChomeNS 2022-12-28 14:04:13 +07:00
parent a6f4c9f035
commit bb26fe5ba0

View file

@ -61,29 +61,11 @@ function inject (bot, dcclient, config) {
bot.command_handler.main(prefix, username, message, sender, channeldc, hash, ownerhash, selector, proxy)
}
}
let previousMessage = { username: '', message: '' }
let ratelimit = 0
bot.on('chat', async (_username, _message) => {
// try catch cuz TypeError: Cannot read properties of undefined (reading 'replace')
try {
if (
previousMessage.username === _username &&
previousMessage.message === _message
) {
if (ratelimit === 3) ratelimit = 0
ratelimit++
return
}
previousMessage = { username: _username, _message }
const username = _username.replace(/§.?/g, '')
const sender = bot.players.list.find((val) => val.name === username)?.UUID
const message = _message.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '') */
bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash)
} catch (e) {
bot.console.error(e)
}
const username = _username?.replace(/§.?/g, '')
const sender = bot.players.list.find((val) => val.name === username)?.UUID
const message = _message?.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '') */
bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash)
})
bot.on('cspy', async function (_username, _message) {
const username = _username.replace(/§.?/g, '')