Reputation: 13
The code is here. In line 41, user.joinedAt
displays the current date and time instead of the user's joined-in date. What is the issue there? I have done research online but those either display the current time or errors in my console. I heard that I would have to use member.joinedAt
, but then I would have to define "member". "user" is already defined as you can conclude in the code.
Upvotes: 0
Views: 206
Reputation: 1802
A User
does not have a joinedAt
property. Therefore, the date being used is: moment.utc(undefined)
, which defaults to the latest date.
Instead, you need to use a GuildMember
. In your code, you can do this by using message.mentions.members
:
let member = message.mentions.members.first();
However, you are also using user.createdAt
, which a GuildMember
does not have. You can access the createdAt
property through the GuildMember.user
property, which contains the createdAt
property:
let user = member.user;
Then you can use the correct values like so:
let embed = new Discord.MessageEmbed()
.setTitle(`Userinfo`)
.setColor(`BLUE`)
.setThumbnail(user.avatarURL({ size: 2048, dynamic: true }))
.addFields (
{name: `Username + tag`, value: `${user.tag}`, inline: true},
{name: `Server join date`, value: `${moment.utc(member.joinedAt).format("dddd, MMMM Do YYYY, h:mm:ss a")} UTC`, inline: true },
{name: `User creation date`, value: `${moment.utc(user.createdAt).format("dddd, MMMM Do YYYY, h:mm:ss a")} UTC`, inline: true}
);
Upvotes: 1