mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
fix bad code
This commit is contained in:
parent
04e8cf29f2
commit
22a94a6daa
1 changed files with 6 additions and 3 deletions
|
@ -61,18 +61,21 @@ function inject (bot, dcclient, config) {
|
||||||
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector)
|
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let previousMessage = ''
|
let previousMessage = { username: '', message: '' }
|
||||||
let ratelimit = 0
|
let ratelimit = 0
|
||||||
bot.on('message', async (_username, _message, _sender) => {
|
bot.on('message', async (_username, _message, _sender) => {
|
||||||
// try catch cuz TypeError: Cannot read properties of undefined (reading 'replace')
|
// try catch cuz TypeError: Cannot read properties of undefined (reading 'replace')
|
||||||
try {
|
try {
|
||||||
if (previousMessage === `${_username}: ${_message}`) { // ig not the best code
|
if (
|
||||||
|
previousMessage.username === _username &&
|
||||||
|
previousMessage.message === _message
|
||||||
|
) {
|
||||||
if (ratelimit === 3) ratelimit = 0
|
if (ratelimit === 3) ratelimit = 0
|
||||||
ratelimit++
|
ratelimit++
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
previousMessage = `${_username}: ${_message}`
|
previousMessage = { username: _username, _message }
|
||||||
|
|
||||||
const usernameraw = _username.replace(/§.?/g, '')
|
const usernameraw = _username.replace(/§.?/g, '')
|
||||||
const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw]
|
const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw]
|
||||||
|
|
Loading…
Reference in a new issue