admin管理员组文章数量:1336321
I'm making a user info mand, and I've e to trying to show when the account was created. The bot responds to &profile {user ping/user ID}, if there are no arguments, it shows info about the executer of the mand. My code looks like this:
const { DiscordAPIError } = require("discord.js");
const Discord = require('discord.js');
const moment = require('moment');
module.exports = {
name: 'profile',
description: "The bot will return the info about the user",
execute(message, args){
let userinfoget = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.member(message.author)
const embed = new Discord.MessageEmbed()
.setColor('#DAF7A6') // or .setColor('RANDOM')
.setAuthor(`${userinfoget.user.tag}`, userinfoget.user.displayAvatarURL())
.addFields(
{name: `User ping`,
value: `<@${userinfoget.id}>`}
)
.addFields(
{name: `User ID`,
value: `${userinfoget.id}`}
)
.addFields(
{name: 'Joined server',
value: moment(userinfoget.joinedAt).format('LLLL')}
)
.addFields(
{name: 'Joined Discord',
value: moment(userinfoget.createdAt).format('LLLL')}
.addFields(
{name: 'Online Status',
value: `${userinfoget.presence.status}`}
)
.setFooter('Bot made by mkpanda')
message.channel.send(embed);
}
}
The time when the user joined the server is displayed correctly, but the account creation is always the current time. Any way to fix it?
I'm making a user info mand, and I've e to trying to show when the account was created. The bot responds to &profile {user ping/user ID}, if there are no arguments, it shows info about the executer of the mand. My code looks like this:
const { DiscordAPIError } = require("discord.js");
const Discord = require('discord.js');
const moment = require('moment');
module.exports = {
name: 'profile',
description: "The bot will return the info about the user",
execute(message, args){
let userinfoget = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.member(message.author)
const embed = new Discord.MessageEmbed()
.setColor('#DAF7A6') // or .setColor('RANDOM')
.setAuthor(`${userinfoget.user.tag}`, userinfoget.user.displayAvatarURL())
.addFields(
{name: `User ping`,
value: `<@${userinfoget.id}>`}
)
.addFields(
{name: `User ID`,
value: `${userinfoget.id}`}
)
.addFields(
{name: 'Joined server',
value: moment(userinfoget.joinedAt).format('LLLL')}
)
.addFields(
{name: 'Joined Discord',
value: moment(userinfoget.createdAt).format('LLLL')}
.addFields(
{name: 'Online Status',
value: `${userinfoget.presence.status}`}
)
.setFooter('Bot made by mkpanda')
message.channel.send(embed);
}
}
The time when the user joined the server is displayed correctly, but the account creation is always the current time. Any way to fix it?
Share asked Aug 31, 2020 at 15:28 PandiconPandicon 4303 gold badges17 silver badges38 bronze badges 1- The problem is that it is getting the creation date of the guildmember, not the user's account. So it's just showing when they joined. You need to make a separate variable for the discord user object instead and get the creation date of that. – Levi_OP Commented Aug 31, 2020 at 15:41
2 Answers
Reset to default 4GuildMember
has no property called createdAt
, only joinedAt
.
You can only get the createdAt
property from the User
object.
moment(userinfoget.user.createdAt)
this is late but just in case someone else sees this: the client id is based of their creation date so you can easily convert it to a unix timestamp
本文标签: javascriptHow to get the date an account was created at discordjs v12Stack Overflow
版权声明:本文标题:javascript - How to get the date an account was created at discord.js v12? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742262270a2442735.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论