Discord.js - .createdAt() is not a valid function

一世执手 提交于 2020-08-10 23:18:59

问题


I'm trying to do is whenever someone joins the server, the bot sends a rich embed with their ID, their user creation date and the new total members, but whenever i run it and test it, it says that .createdAt() is not a valid function, so i'm completely lost as to what to do.


client.on("guildMemberAdd", member => {
  let mlogchannel = member.guild.channels.find((channel => channel.name === "member-logging"));
  if (mlogchannel) {
    console.log(client.users.find(user => user.id === member.id).createdAt())
    var cdate = moment.utc(User.createdAt()).format("dddd, MMMM Do YYYY, HH:mm");
    const sInfo = new Discord.RichEmbed()
      .setTitle(`Member joined`)
      .setAuthor(`${member.displayName}`)
      .setColor(8528115)
      .setFooter(`User ID: ${member.id}`)
      .setTimestamp()
      .setThumbnail(member.user.createdAt())
      .addField("Total members", `${Guild.members.filter(member => !member.user.bot).size}`, true)
      .addField("Creation Date:", `${cdate}`, true);
    let ageS = moment(cdate).fromNow(true)
    let ageA = ageS.split(" ");
    if (ageA[1] = "days" && ageA[2] >= 30) {
      Guild.channels.find((channel => channel.name === "member-logging").send(sInfo));
      mlogchannel.send("**WARNING!**\nThis account is less than 30 days old and may have been made to bypass a server mute or ban!")
    }
    if (ageA[1] != "days") {
      mlogchannel.send(sInfo)
    }
    if (!mlogchannel) {
      return console.log(`${Guild.name}:${Guild.ID} Has not set up a member log channel!`)
    }
  }
})

回答1:


User.createdAt is a property of User, not a method. So instead of .setThumbnail(member.user.createdAt()), it would be .setThumbnail(member.user.createdAt).



来源:https://stackoverflow.com/questions/54393807/discord-js-createdat-is-not-a-valid-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!