Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
How can i make Spam check command mute after warning

I have been messing around with this spam check bot, and i would love to do it so it warns you after first 5 spam messages, and mutes you after 15. I tried to use else if command, but that didnt success that well :D

What should i do?

code:


function spamCheck(msg, set, time) {
    if (msg.member.roles.cache.find(role => role.name === 'Muted')) return

    let bool = false
    let user = { id: msg.author.id, time: Date.now(), times: 1 }

    for(let u of set) {
        if (isNaN(u.times)) u.times = 1

        if (u.id === msg.author.id) {
            bool = true

            if(u.times == 5) {
            msg.reply(`Please Do not spam!`)

    
            

            let muterole = msg.guild.roles.cache.find(role => role.name === 'Muted')
            if(!msg.member.roles.cache.has(muterole.id)) {
                msg.member.roles.add(muterole)

                setTimeout(() => {
                    msg.member.roles.remove(muterole)
                    set.delete(u)
                    msg.channel.send('**Unmuted**')
                }, 5000);
            }
            } else if ((Date.now() - u.time) <= time) {
                u.times++
                u.time = Date.now()
            }
        }
    }

    if (bool === false) {
        set.add(user)
    }
}

module.exports = { spamCheck }```
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!