adding role problem

my code: interaction.guild.members.cache.get(match[1].toString()).roles.add(role) (with match[1] being a user ID) my error: TypeError: Cannot read properties of undefined (reading 'roles')
5 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Speed
SpeedOP2y ago
here's the full error: interaction.guild.members.cache.get(match[1].toString()).roles.add(role) ^ TypeError: Cannot read properties of undefined (reading 'roles') at Client.<anonymous> (/home/runner/Slash-1-server/index.js:208:61) at Client.emit (node:events:390:28) at Client.emit (node:domain:475:12) at InteractionCreateAction.handle (/home/runner/Slash-1-server/node_modules/discord.js/src/client/actions/InteractionCreate.js:83:12) at Object.module.exports [as INTERACTION_CREATE] (/home/runner/Slash-1-server/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36) at WebSocketManager.handlePacket (/home/runner/Slash-1-server/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31) at WebSocketShard.onPacket (/home/runner/Slash-1-server/node_modules/discord.js/src/client/websocket/WebSocketShard.js:493:22) at WebSocketShard.onMessage (/home/runner/Slash-1-server/node_modules/discord.js/src/client/websocket/WebSocketShard.js:327:10) at callListener (/home/runner/Slash-1-server/node_modules/ws/lib/event-target.js:290:14)
treble/luna
treble/luna2y ago
member is not cached or the id provided is invalid
zer0 negative☽
@s_p3 did you solve this? i have same problem
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server