if(target.roles.cache.has('937250064894664734')){
^
TypeError: Cannot read properties of undefined (reading ‘cache’)
at Object.execute (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botcommandsmute.js:6:24)
at Client. (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botmain.js:57:37)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botnode_modulesdiscord.jssrcclientactionsMessageCreate.js:34:18)
at Object.module.exports [as MESSAGE_CREATE] (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botnode_modulesdiscord.jssrcclientwebsockethandlersMESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:351:31)
at WebSocketShard.onPacket (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botnode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botnode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:301:10)
at WebSocket.onMessage (C:UsersmihriOneDriveDesktopAdomisBotAdomis-Botnode_moduleswslibevent-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