Search code examples
javascriptdiscorddiscord.jsavatar

discord.js userID avatarURL in embed


I trying display avatar via userID because it wants that if I changed it, the new one loaded via my user ID in footer in embed will be displayed. Anyone know how on v12? {need without message.author}

else if(isValidCommand(message, "embed")) {
    let embedContent = message.content.substring(9);
    let embed = new discord.MessageEmbed();
    embed.addField('Message: ', embedContent);
    embed.setColor('PURPLE');
    embed.setAuthor(message.author.tag, message.author.avatarURL());
    embed.setThumbnail( client.user.avatarURL());
    embed.setTitle("Func title comming soon");
    embed.setURL(``);
    embed.setDescription("Func description comming soon");
    embed.setImage(``);
    embed.setTimestamp(Date.now());
    embed.setFooter("© 2020 Dominik ~rejzer#9345 | link |", **[USERID .avatarURL or .displayAvatarURL]** ); 
    message.channel.send(embed);
}

Solution

  • I hope you want to get your profile picture to the bottom of the embed. So use following:

     bot.guilds.resolve(guildID).members.resolve(userID).user.avatarURL()
    

    where bot is your client (Discord.Client()), guildID is id of guild you're in and userID is your Id (or user you want to display profile picture of).