Cannot read properties of undefined "options"

/home/container/events/join.js:13
const role = member.interaction.options.getRole('905893175774822441');
^
TypeError: Cannot read properties of undefined (reading 'options')
at Object.execute (/home/container/events/join.js:13:37)
at Client.<anonymous> (/home/container/index.js:47:44)
at Client.emit (node:events:513:28)
at module.exports [as GUILD_MEMBER_ADD] (/home/container/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1173:51)
at WebSocketShard.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.onMessage (/home/container/node_modules/@discordjs/ws/dist/index.js:988:14)
/home/container/events/join.js:13
const role = member.interaction.options.getRole('905893175774822441');
^
TypeError: Cannot read properties of undefined (reading 'options')
at Object.execute (/home/container/events/join.js:13:37)
at Client.<anonymous> (/home/container/index.js:47:44)
at Client.emit (node:events:513:28)
at module.exports [as GUILD_MEMBER_ADD] (/home/container/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1173:51)
at WebSocketShard.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.onMessage (/home/container/node_modules/@discordjs/ws/dist/index.js:988:14)
4 Replies
d.js toolkit
d.js toolkit16mo 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!
SuperPEKKA336
SuperPEKKA336OP16mo ago
const {Events} = require('discord.js');

const {EMBEDS, WELCOME} = require('../constants.json')

module.exports =
{
name: Events.GuildMemberAdd,

execute(member)
{
console.log('User joined the server.');
const channel = member.client.channels.cache.get('779040966551273553');
const role = member.interaction.options.getRole('905893175774822441');

const embed = EMBEDS.WELCOME;

embed.description = embed.description.replaceAll("%user", member.id);

channel.send(
{
embeds: [embed]
});

member.roles.add(role);
},
};
const {Events} = require('discord.js');

const {EMBEDS, WELCOME} = require('../constants.json')

module.exports =
{
name: Events.GuildMemberAdd,

execute(member)
{
console.log('User joined the server.');
const channel = member.client.channels.cache.get('779040966551273553');
const role = member.interaction.options.getRole('905893175774822441');

const embed = EMBEDS.WELCOME;

embed.description = embed.description.replaceAll("%user", member.id);

channel.send(
{
embeds: [embed]
});

member.roles.add(role);
},
};
join.js
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
SuperPEKKA336
SuperPEKKA336OP16mo ago
k
Want results from more Discord servers?
Add your server