#target.joinedAt is returning to be undefined
31 messages · Page 1 of 1 (latest)
Show the code where you get the user option
use getMember since joinedAt is a property of GuildMember
It’s a slash command
The code there is where it gets the user
Could I just do target.getMember?
No, that code is where you tell discord that users should be able to put a user into that option. It‘s not where your bot gets the user from the interaction
No
Target.createdTimestamp gives the correct value so it is getting the user I select in that field
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
TypeError: Cannot read properties of undefined (reading 'members')
const target = interaction.options.getUser('user');
const guildTarget = guild.members.fetch(target.id)
use .getMember
that doesnt seem to exist
Show the error
.getMember doesnt exist dude
TypeError: Cannot read properties of undefined (reading 'members')
this is the error
here
interaction.options.getMember
I dont want the user the issued the command I want the selected user
And guild isn't defined
use getMember
That is literally what getMember does
Show your new code
async execute(interaction) {
const target = interaction.options.getUser('user');
const guildTarget = interaction.option.getMember('user')
const exampleEmbed = new EmbedBuilder()
.setColor(212121)
.setAuthor({ name: `User info for ${target.tag}` })
.setDescription('Some description here')
.setThumbnail(`${target.displayAvatarURL()}`)
.addFields(
{ name: 'User ID', value: `${target.id}` },
{ name: 'The user has had Discord for:', value: `${timeSince(new Date(target.createdTimestamp))}` },
{ name: 'The user has been in the server for', value: `${timeSince(new Date(guildTarget.joinedAt))}` },
)
.setTimestamp()
.setFooter({ text: `Command issued by ${interaction.user.tag}`, iconURL: ` ${interaction.user.displayAvatarURL()}` });
return interaction.reply({ embeds: [exampleEmbed], ephemeral: false });
},
};
@hallow hollow
options not option man
oh lol