guildMemberAdd problem

const profileModel = require('../Economy/profiles.js');
const { EmbedBuilder } = require('discord.js')

module.exports = {
name: 'guildMemberAdd',
on: true,
async execute( message, client, discord, member){
const logChannel = message.client.channels.cache.get('998976798358503525')
const memberJoinLogEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Guid Member Add Trigger')
.setDescription('A new member has joined')
.setTimestamp()
logChannel.send({ embeds: [memberJoinLogEmbed]})
let profile = await profileModel.create({
userID: member.id,
serverID: member.guild.id,
kai: 500,
bank: 500
});
profile.save()
}
}
const profileModel = require('../Economy/profiles.js');
const { EmbedBuilder } = require('discord.js')

module.exports = {
name: 'guildMemberAdd',
on: true,
async execute( message, client, discord, member){
const logChannel = message.client.channels.cache.get('998976798358503525')
const memberJoinLogEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Guid Member Add Trigger')
.setDescription('A new member has joined')
.setTimestamp()
logChannel.send({ embeds: [memberJoinLogEmbed]})
let profile = await profileModel.create({
userID: member.id,
serverID: member.guild.id,
kai: 500,
bank: 500
});
profile.save()
}
}
12 Replies
d.js docs
d.js docs3y 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.
PAdventures
PAdventuresOP3y ago
Error
node:events:498
throw er; // Unhandled 'error' event
^

ReferenceError: member is not defined
at Object.execute (D:\PA_Admin Backup\Events\guildMemberAdd.js:16:21)
at Client.<anonymous> (D:\PA_Admin Backup\index.js:55:44)
at Client.emit (node:events:520:28)
at Object.module.exports [as GUILD_MEMBER_ADD] (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
at WebSocketShard.onMessage (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
at WebSocket.onMessage (D:\PA_Admin Backup\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:520:28)
at Receiver.receiverOnMessage (D:\PA_Admin Backup\node_modules\ws\lib\websocket.js:1178:20)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
node:events:498
throw er; // Unhandled 'error' event
^

ReferenceError: member is not defined
at Object.execute (D:\PA_Admin Backup\Events\guildMemberAdd.js:16:21)
at Client.<anonymous> (D:\PA_Admin Backup\index.js:55:44)
at Client.emit (node:events:520:28)
at Object.module.exports [as GUILD_MEMBER_ADD] (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
at WebSocketShard.onMessage (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
at WebSocket.onMessage (D:\PA_Admin Backup\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:520:28)
at Receiver.receiverOnMessage (D:\PA_Admin Backup\node_modules\ws\lib\websocket.js:1178:20)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP3y ago
how do i get the "member" id
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP3y ago
node:events:498
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'id')
at Object.execute (D:\PA_Admin Backup\Events\guildMemberAdd.js:16:28)
at Client.<anonymous> (D:\PA_Admin Backup\index.js:55:44)
at Client.emit (node:events:520:28)
at Object.module.exports [as GUILD_MEMBER_ADD] (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
at WebSocketShard.onMessage (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
at WebSocket.onMessage (D:\PA_Admin Backup\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:520:28)
at Receiver.receiverOnMessage (D:\PA_Admin Backup\node_modules\ws\lib\websocket.js:1178:20)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
node:events:498
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'id')
at Object.execute (D:\PA_Admin Backup\Events\guildMemberAdd.js:16:28)
at Client.<anonymous> (D:\PA_Admin Backup\index.js:55:44)
at Client.emit (node:events:520:28)
at Object.module.exports [as GUILD_MEMBER_ADD] (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:17:14)
at WebSocketManager.handlePacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
at WebSocketShard.onMessage (D:\PA_Admin Backup\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
at WebSocket.onMessage (D:\PA_Admin Backup\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:520:28)
at Receiver.receiverOnMessage (D:\PA_Admin Backup\node_modules\ws\lib\websocket.js:1178:20)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:381:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
new error, note: i have changed code at the top
d.js docs
d.js docs3y ago
class GuildMember (extends Base) Represents a member of a guild on property GuildMember#user The user that this guild member instance property GuildMember#id The member's id
PAdventures
PAdventuresOP3y ago
Im going to be "offline" for 30-50 mins, please help me with finding the members id
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP3y ago
guildMemberAdd not messageCreate ^
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP3y ago
i fixed the problem
Want results from more Discord servers?
Add your server