嵌入中提到的用户avatarUrl

时间:2020-07-27 20:48:11

标签: discord.js

我有一个有关从提到的用户添加avatarUrl的问题。我已经完成了代码,但是在发送嵌入文件时没有显示图像。控制台中也没有错误。

        const user = message.mentions.users.first();
        var mention = "<@" + user.id + ">"
        var userCreated = user.createdAt.toString().split(" ");
        var userJoined = user.userJoined
        const Embed = new Discord.MessageEmbed()
            .setTitle(user.tag)
            .setDescription(mention)
            .setColor("#b60303")
            .addFields(
                { name: "Registered at", value: userCreated[1] + " " + userCreated[2] + ", " + userCreated[3]},
                { name: "ID", value: user.id, inline: true}
            )
            .setImage(message.avatarURL)
            .setTimestamp()
            .setFooter("ID: " + user.id)
        
        message.channel.send(Embed)

    }```

1 个答案:

答案 0 :(得分:1)

消息没有头像URL,在Discord JS v12中,avatarURL是一种方法。

.setImage(message.author.avatarURL())