当前,我正在处理一个命令,当您键入 me 时,它将显示有关您的信息。 这是我的代码:
var member = message.guild.member(message.member);
var status = member.presence.status;
var nickName = member.nickname;
if(nickName == null || undefined) nickName = "None";
var accountCreated = moment(member.createdAt).format("LL");
var joinedGuild = moment(member.joinedAt).format("LL");
var game = member.presence.activities[0] ? member.presence.activities[0].name : "None";
var botEmbed = new discord.MessageEmbed()
.setTitle(`USER INFO`)
.setDescription(`See info about ${member.username} below!`)
.setColor(embedColor)
.setFooter(embedFooter)
.setTimestamp()
.setThumbnail(member.displayAvatarURL({size: 4096}))
.addFields(
{name: "User Name", value: member.username, inline: true},
{name: "User ID", value: member.id, inline: true},
{name: "User Account Created", value: accountCreated, inline: true},
{name: "\u200b", value: "\u200b"},
{name: "User Status", value: status, inline: true},
{name: "User Game", value: game, inline: true},
{name: "User Nickname", value: nickName, inline: true},
{name: "\u200b", value: "\u200b"},
{name: "User Joined Server At", value: joinedGuild}
);
return message.channel.send(botEmbed);
但是,我收到一个错误: TypeError:member.displayAvatarURL不是一个函数 而且我已经尝试了很多方法,但是似乎没有任何效果。
答案 0 :(得分:1)
member
对象没有名为displayAvatarURL
的方法。
好消息是user
对象确实可以。因此,只需在其中放置.user
即可。