I'm working to try and develop a Discord.js bot. However, I've run into an issue I can't find a fix for. These two chunks of code (formatted how I like it) are supposed to send join and leave messages in a specific discord channel. I'm rather new to coding, so I don't know what the issue is. When a user leaves, nothing happens, and when a user joins, the bot crashes with an error I can't understand. I assumed it was part of the code that's getting user info, such as Discord.GuildMember.user.id, but I've tried every other variation of it I've used for the rest of the code. I'm unsure what's not working. Thank you for any help in advance!
client.on("guildMemberAdd", message => {
const currentDate = new Date();
const timestampInMs = currentDate.getTime();
const unixTimestamp = Math.floor(currentDate.getTime() / 1000);
const userJoined = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(`${Discord.GuildMember.username} joined the server.`)
.setDescription(`Joined: <@${Discord.GuildMember.user.id}> **Account Created**: ${Discord.GuildMember.user.createdAt}`)
.setAuthor({ name: `User Logging System`, iconURL: (Discord.GuildMember.avatarURL()) })
.addFields(
{ name: `User ID`, value: `${Discord.GuildMember.user.id}` },
{ name: `Timestamp`, value: `<t:${unixTimestamp}>`}
)
.setFooter({ text: `${currentDate}` })
{client.channels.cache.get("1010193667975282698")
.send ({ embeds: [userJoined] });
}});
client.on("guildMemberRemove", message => {
const currentDate = new Date();
const timestampInMs = currentDate.getTime();
const unixTimestamp = Math.floor(currentDate.getTime() / 1000);
const userLeft = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(`${Discord.GuildMember.username} left the server.`)
.setDescription(`Left: <@${Discord.GuildMember.user.id}> **Account Created**: ${Discord.GuildMember.user.createdAt}`)
.setAuthor({ name: `User Logging System`, iconURL: (Discord.GuildMember.avatarURL()) )
.addFields(
{ name: `User ID`, value: `${Discord.GuildMember.user.id}` },
{ name: `Timestamp`, value: `<t:${unixTimestamp}>`}
)
.setFooter({ text: `${currentDate}` })
{client.channels.cache.get("1010666655615029259")
.send ({ embeds: [userLeft] });
}});