#how can I catch this?
16 messages · Page 1 of 1 (latest)
• 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.
Then you seem to have a catch somewhere that silently ignores the error… or you didn’t check the console for errors. Because mention will be undefined in your case and thus you can’t access any properties on it
this is the console error, I searched about it but nothing that actually helps
You pass your args[0] to the get without making sure it‘s a id. Try using guild.members.resolve(…) instead and check if it exists before trying to access properties
it works fine with mentions but id mentions didnt work now 
What does your code look like now?
////////////////AVATAR////////////////
client.on('messageCreate', async message => {
const prefix = "tr.";
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(message.content.toLowerCase().startsWith(prefix))
{
if(command === "av") {
let mention = message.mentions.users.first().id || (await message.guild.members.fetch(args[0])).id
let m = mention.username
if(mention.id == undefined) return;
const embed = new MessageEmbed()
.setColor(`0x2F3136`)
.setDescription('aqui esta el avatar 👍')
.setImage(await mention.displayAvatarURL({size: 4096, dynamic: true}))
.setFooter({text: `Avatar de ${m}`})
message.reply({ embeds: [embed] }).catch(() => null)
}
}
});
Why did you make mention the id now? Strings don’t have .id or .username property
And it will obviously fail again if the fetch returns undefined
I was trying any thing just in case
obviously didnt work

just add a .catch(() => null) after the fetch and then check if mention exists
something like:
let mention = message.mentions.users.first() || await message.guild.members.fetch(args[0]).catch(() => null);
if(!mention) return message.channel.send('No user found')
BTW you don't need the await in the displayAvatarURL function