Reputation: 126
I'm making a DiscordJS Bot and I have an issue with my userinfo
command.
I want to know when the user joins the guild, and it replies with the date of today. I'm sure the user didn't join today.
Here's my code
const user = message.mentions.users.first() || bot.users.cache.get(args[0]) || message.author;
if (!user) return message.channel.send("Utilisateur introuvable")
.then(message => {
message.delete({
timeout: 3000
})
}).catch(e => {
console.log(e)
});
const userStatus = {
online: "<:Online:697378421319270401> En ligne",
idle: "<:Idle:697378421130395749> Inactif",
dnd: "<:DND:697378421386248282> Ne pas déranger",
offline: "<:Off:697378421264875594> Hors ligne"
}
if (user.bot) {
isBot = "Oui";
} else {
isBot = "Non";
}
const uiEmbed = new MessageEmbed()
.setAuthor(user.username)
.setColor(message.member.displayHexColor)
.setThumbnail(user.displayAvatarURL({
dynamic: true
}))
.addField("Pseudo et Tag", "<:Discord:697378425178030171> " + user.tag, true)
.addField("Surnom", `${message.guild.members.resolveID(user.id).nickame || "Aucun Surnom"}`, true)
.addField("ID", "<:ID:697380447876808716> " + user.id, true)
.addField("Bot ?", "<:Bot:697378421163950152> " + isBot, true)
.addField("Compte créé le :", "<:Dis:697380487785873499> " + moment(user.createdAt).format("LL"), true)
.addField("Status", userStatus[user.presence.status], true)
.addField(Compte créé le: , moment(message.guild.members.resolveID(user.id).joinedAt).format("LL"), true)
.setFooter(`Commande effectuée par ${message.author.username} | Azaziell`)
message.channel.send(uiEmbed);
As you can see in my code, it's a French bot ^^" So, the issue is in the line that says Compte créé le :
And I'm using the version 12.1.1 of discord.js
Upvotes: 0
Views: 376
Reputation: 398
The way you defined user is getting the info for the user, you need to specify you want the info for the user in the guild, so do this instead:
let member = message.guild.member(message.author);
console.log(member.joinedAt);
This gives me the result I assume you want:
2020-05-02T12:36:53.445Z
wich you can then format
Upvotes: 1