getTime is undefined

.setDescription(`**Username:** <@${user}> (${user_id})\n**Action:** User Joined\n**Joined At:** <t:${Math.floor(member.user.joinedAt.getTime() / 1000)}:F>`)
.setDescription(`**Username:** <@${user}> (${user_id})\n**Action:** User Joined\n**Joined At:** <t:${Math.floor(member.user.joinedAt.getTime() / 1000)}:F>`)
<rejected> TypeError: Cannot read properties of undefined (reading 'getTime')
at C:\Users\levit\Downloads\blonde\Events\Modlogs\guildMemberAdd.js:24:150
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
} reason TypeError: Cannot read properties of undefined (reading 'getTime')
at C:\Users\levit\Downloads\blonde\Events\Modlogs\guildMemberAdd.js:24:150
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
<rejected> TypeError: Cannot read properties of undefined (reading 'getTime')
at C:\Users\levit\Downloads\blonde\Events\Modlogs\guildMemberAdd.js:24:150
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
} reason TypeError: Cannot read properties of undefined (reading 'getTime')
at C:\Users\levit\Downloads\blonde\Events\Modlogs\guildMemberAdd.js:24:150
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
14 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.
Danial
Danial2y ago
Users don't have joinedAt, members do
papa elf
papa elfOP2y ago
ah, alr i've been using member.user for the events so i just assumed it would be the same works! thanks for the help.
Danial
Danial2y ago
Of course
papa elf
papa elfOP2y ago
one last thing, whats the property for a member leaving the guild?
Danial
Danial2y ago
The property, like when they left the guild?
papa elf
papa elfOP2y ago
yeah
Danial
Danial2y ago
There isn't one, you'd use Date.now() in guildMemberRemove event
papa elf
papa elfOP2y ago
ohh right i completely forgot about that my bad
Danial
Danial2y ago
All good
papa elf
papa elfOP2y ago
im getting the same error once i added more to it, but i didn't change anything besides createdAt
.setDescription(`**Username:** <@${user_id}> - **${user}** (${user_id})\n**Action:** User Joined\n**Created At:** <t:${Math.floor(member.createdAt.getTime() / 1000)}:F> (<t:${Math.floor(member.createdAt.getTime() / 1000)}:R>)\n**Joined At:** <t:${Math.floor(member.joinedAt.getTime() / 1000)}:F> (<t:${Math.floor(member.joinedAt.getTime() / 1000)}:R>)`)
.setDescription(`**Username:** <@${user_id}> - **${user}** (${user_id})\n**Action:** User Joined\n**Created At:** <t:${Math.floor(member.createdAt.getTime() / 1000)}:F> (<t:${Math.floor(member.createdAt.getTime() / 1000)}:R>)\n**Joined At:** <t:${Math.floor(member.joinedAt.getTime() / 1000)}:F> (<t:${Math.floor(member.joinedAt.getTime() / 1000)}:R>)`)
Danial
Danial2y ago
Members don't have createdAt property, users do, so this time you'd put member.user.createdAt
d.js docs
d.js docs2y ago
Despite sounding similar there is a distinct difference between users and members in Discord: - User: global Discord user data (global avatar, username, tag, id) - GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.) - Conversion: User ➞ GuildMember | GuildMember ➞ User * Note: Events received in cached guilds will often have both the member and user available, eg. interaction.user and interaction.member
papa elf
papa elfOP2y ago
alr, 😭
Want results from more Discord servers?
Add your server