TypeError: Cannot read properties of undefined (reading 'id')

    async execute(interaction) {
        const member = interaction.member;

        if(member.roles.cache.some(role => role.name === 'Mod')){
            interaction.reply({ content: "Links", ephemeral: true });
        }else {
            interaction.reply({ content: "You don't have permission to use this command.", ephemeral: true });
        }
    }

always returns in
TypeError: Cannot read properties of undefined (reading 'id')
    at get cache [as cache] (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:37:101)
    at Object.execute (C:\Users\lschu\Documents\Workspace\hldiscordbot\src\commands\links.js:13:25)
    at Client.<anonymous> (C:\Users\lschu\Documents\Workspace\hldiscordbot\src\index.js:30:23)
    at Client.emit (node:events:514:28)
    at InteractionCreateAction.handle (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
    at module.exports [as INTERACTION_CREATE] (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
    at WebSocketManager.<anonymous> (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
    at WebSocketManager.emit (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
    at WebSocketShard.<anonymous> (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\@discordjs\ws\dist\index.js:1173:51)
TypeError: Cannot read properties of undefined (reading 'id')
    at get cache [as cache] (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:37:101)
    at Object.execute (C:\Users\lschu\Documents\Workspace\hldiscordbot\src\commands\links.js:13:25)
    at Client.<anonymous> (C:\Users\lschu\Documents\Workspace\hldiscordbot\src\index.js:30:23)
    at Client.emit (node:events:514:28)
    at InteractionCreateAction.handle (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
    at module.exports [as INTERACTION_CREATE] (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
    at WebSocketManager.<anonymous> (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
    at WebSocketManager.emit (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
    at WebSocketShard.<anonymous> (C:\Users\lschu\Documents\Workspace\hldiscordbot\node_modules\@discordjs\ws\dist\index.js:1173:51)
Was this page helpful?