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

252
Views
TypeError: Cannot read property 'permissions' of null discord.js v13

I was trying to make an anti-link bad word thing and it doesn't understand roles I suppose.

This is the error I'm getting:

if(message.member.permissions.has('MANAGE_MESSAGES')) return
                    ^
TypeError: Cannot read property 'permissions' of null

And this is my code:

    const fs = require('fs')
    module.exports = (client) => {
    client.on('message', async message => {
      if(message.member.permissions.has('MANAGE_MESSAGES')) return
        let warnings = {}
        let warnCount = 3
        let warnCount2 = 5
        let warnCount3 = 7
        warnings = fs.readFileSync('./db.json', 'utf8');
        warnings = JSON.parse(warnings)
          if(message.content.toLowerCase().includes('fuk')) {
            await message.delete()
            await message.channel.send(`${message.author.username} was warned for posting links`)
            if(!warnings[message.author.id]) warnings[message.author.id] = {
              warnings: 0
            }
            warnings[message.author.id].warnings += 1
            console.log(`${message.author.tag} was warned in ${message.guild.name}. Warnings: ${warnings[message.author.id].warnings}`)
            if(warnings[message.author.id].warnings == warnCount){
             let muterole = message.guild.roles.cache.find(role => role.name === 'Muted')
             if(!muterole) return message.channel.send('cant mute because theres no roles such as "Muted"')
             await message.guildMember.roles.add(muterole)
             await message.channel.send(`${message.author.tag} was muted for 1m. Reason: Unknown Link`)
             setTimeout(async() => {
               await message.member.roles.remove(muterole)
               await message.channel.send(`${message.author.tag} was unmuted`)
             }, 60000)
           }
           if(warnings[message.author.id].warnings == warnCount2){
             let muterole = message.guild.roles.cache.find(role => role.name === 'Muted')
             if(!muterole) return message.channel.send('cant mute because theres no roles such as "Muted"')
             await message.guildMember.roles.add(muterole)
             await message.channel.send(`${message.author.tag} was muted for 1h. Reason: Unknown Link`)
             setTimeout(async() => {
               await message.member.roles.remove(muterole)
               await message.channel.send(`${message.author.tag} was unmuted`)
             }, 3600000)
           }
          fs.writeFileSync('./db.json', JSON.stringify(warnings));
        })
    }
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!