本文介绍了Discord.js-.createdAt()不是有效的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做的是,只要有人加入服务器,机器人就会发送带有其ID,用户创建日期和新成员总数的丰富内嵌程序,但是每当我运行并对其进行测试时,它都会说 .createdAt()
不是有效的函数,所以我完全不知道该怎么做。
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!`)
}
}
})
推荐答案
User.createdAt
是属性用户的em>,而不是方法。因此,它不是 .setThumbnail(member.user.createdAt())
,而是 .setThumbnail(member.user.createdAt)
。
User.createdAt
is a property of User, not a method. So instead of .setThumbnail(member.user.createdAt())
, it would be .setThumbnail(member.user.createdAt)
.
这篇关于Discord.js-.createdAt()不是有效的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!