how can I catch this?

Im working in a avatar command that works with ID and mentions, but when a type something like "!avatar hello" didn't catch nothing and dies :(
5 Replies
d.js docs
d.js docs2y 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.
TRKako
TRKako2y ago
this is the console error, I searched about it but nothing that actually helps
TRKako
TRKako2y ago
it works fine with mentions but id mentions didnt work now poto
////////////////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)
}
}
});
////////////////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)
}
}
});
I was trying any thing just in case obviously didnt watawhat
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
TRKako
TRKako2y ago
thx, it worked sisi