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

120
Views
I Can Understand This Error Someone Help Please
  if(target.roles.cache.has('937250064894664734')){
                   ^

TypeError: Cannot read properties of undefined (reading 'cache') at Object.execute (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\commands\mute.js:6:24) at Client. (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\main.js:57:37) at Client.emit (node:events:390:28) at MessageCreateAction.handle (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:34:18) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31) at WebSocketShard.onPacket (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22) at WebSocketShard.onMessage (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) at WebSocket.onMessage (C:\Users\mihri\OneDrive\Desktop\Adomis\Bot\Adomis-Bot\node_modules\ws\lib\event-target.js:199:18) at WebSocket.emit (node:events:390:28)

The Error

module.exports ={ name: 'mute', description: 'Mute Command', execute(message, args){ const target = message.mentions.users.first(); if(target.roles.cache.has('937250064894664734')){ if(target){ let mainRole = message.guild.cache.find(role => role.name === 'member') let mutedRole = message.guild.cache.find(role => role.name === 'muted')

        let memberTarget = message.guild.members.cache.get(target.id);
        memberTarget.roles.remove(mainRole.id)
        memberTarget.roles.add(mutedRole)

        message.channel.send("Kullanici Susturulmustur!")
    }

    else{
        message.channel.send("Kullanici Bulunamamistir!")
    }
   }

   else{
       message.channel.send("Bu Komutu Kullanmak Icin Yetkin Yoktur!")
   }
}

}

The Code

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It means that whether target.roles or target itself is undefined. You should validate it first such as:

 if (target && target.roles && target.roles.cache && target.roles.cache.has('937250064894664734')) {
   ....
 }

Anyway, you can just

 if (target?.roles?.cache?.has('...')) {
  ...
 }
about 4 years ago · Juan Pablo Isaza Report
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!