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 });
}
}
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)
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)
6 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
(ɔ◔◡◔)ɔLuftigerLuca
Discord.js version: 14.13.0 Node version: v18.17.1
treble/luna
treble/luna13mo ago
do you have the Guilds intent
(ɔ◔◡◔)ɔLuftigerLuca
Guildmembers?
treble/luna
treble/luna13mo ago
no, Guilds
(ɔ◔◡◔)ɔLuftigerLuca
thx, this was the causing the error :)
Want results from more Discord servers?
Add your server