how can I check if member has avatar by server or normal avatar?

I have an avatar command that works fine except with people with avatar by server, what can I do? trroxyynoladefnafsecuritybreach here's the code
if (command === "avatar"){

let member = message.mentions.users.first() || await message.guild.members.fetch(args[0]).catch(() => null) || message.author;
let avatar = member.displayAvatarURL({ size: 4096, dynamic: true });

const embed = new Discord.MessageEmbed()
.setTitle('Avatar šŸ‘')
.setColor(`0x2F3136`)
.setDescription(`Avatar de <@${member.id}>`)
.setImage(avatar)
message.reply({embeds: [embed]})
}
if (command === "avatar"){

let member = message.mentions.users.first() || await message.guild.members.fetch(args[0]).catch(() => null) || message.author;
let avatar = member.displayAvatarURL({ size: 4096, dynamic: true });

const embed = new Discord.MessageEmbed()
.setTitle('Avatar šŸ‘')
.setColor(`0x2F3136`)
.setDescription(`Avatar de <@${member.id}>`)
.setImage(avatar)
message.reply({embeds: [embed]})
}
4 Replies
d.js docs
d.js docsā€¢3y ago
ā€¢ What's your exact discord.js npm list discord.js and node node -v version? ā€¢ Post the full error stack trace, not just the top part! ā€¢ Show your code! ā€¢ Explain what exactly your issue is. ā€¢ Not a discord.js issue? Check out #useful-servers.
monbrey
monbreyā€¢3y ago
You're being really inconsistent getting user/member If you make sure you get a member all the time it should work fine
TRKako
TRKakoOPā€¢3y ago
and how can I do that? I tried changing the let avatar part to this thing
//let avatar = member.defaultAvatarURL({ size: 4096, dynamic: true });
let url = member.displayAvatarURL == undefined ? member.defaultAvatarURL : member.avatarURL({ size: 4096, dynamic: true });
//let avatar = member.defaultAvatarURL({ size: 4096, dynamic: true });
let url = member.displayAvatarURL == undefined ? member.defaultAvatarURL : member.avatarURL({ size: 4096, dynamic: true });
didn't work amogu not that, it's that I didn't understand what I was supposed to change holie I felt bad for asking again so I better look it up on Internet <:9_:991720192549851166>
chewie
chewieā€¢3y ago
message.member.avatarURL() returns null if the member doesnt have a member avatar thats the only check you need but if you just want the url, you can just use member.displayAvatarURL() which returns the member avatar url if there is one or the users default avatar
Want results from more Discord servers?
Add your server