mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 01:25:33 -05:00
um ig ratelimit better
This commit is contained in:
parent
5c27a494c6
commit
04e8cf29f2
1 changed files with 8 additions and 6 deletions
|
@ -61,16 +61,18 @@ function inject (bot, dcclient, config) {
|
|||
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector)
|
||||
}
|
||||
}
|
||||
let previousMessage = { username: '', message: '' }
|
||||
let previousMessage = ''
|
||||
let ratelimit = 0
|
||||
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
|
||||
if (previousMessage === `${_username}: ${_message}`) { // ig not the best code
|
||||
if (ratelimit === 3) ratelimit = 0
|
||||
ratelimit++
|
||||
return
|
||||
}
|
||||
|
||||
previousMessage = { username: _username, message: _message }
|
||||
previousMessage = `${_username}: ${_message}`
|
||||
|
||||
const usernameraw = _username.replace(/§.?/g, '')
|
||||
const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw]
|
||||
|
|
Loading…
Reference in a new issue