Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
member returns undefined for no apparent reason

For some reason whenever I try to run this code it only responds with the else Block instead of the wanted if (member) result

(Before I get comments saying: "Well clearly the User is not in the Guild." that's the Case here) lol

let member = msg.mentions.members.first() || msg.guild.members.cache.get(args[0]);
console.log(member);
if (member) {
    try {
        const userInfo = new MessageEmbed()
            .setAuthor({ name: `${member.user.tag}`, iconURL: member.user.displayAvatarURL({ dynamic: true }) })
            .setColor("BLUE")
            .setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
            .setTitle("User Info")
            .setDescription(
                `**Tag:** ${member.user.tag}\n**ID:** ${member.user.id}\n**Bot:** ${member.user.bot ? "✅" : "❌"}\n**Created At: <t:${Math.round(parseInt(member.user.createdTimestamp) / 1000)}:F>**\n**Joined At: <t:${Math.round(
                    parseInt(member.joinedTimestamp) / 1000
                )}:F>**`
            )
            .setTimestamp();
        return msg.channel.send({ embeds: [userInfo] });
    } catch (err) {
        log(err);
        return;
    }
} else {
    try {
        let fetching = await client.users.fetch(args[0]);
        const userInfo = new MessageEmbed()
            .setAuthor({ name: `${fetching.tag}`, iconURL: fetching.displayAvatarURL({ dynamic: true }) })
            .setColor("BLUE")
            .setThumbnail(fetching.displayAvatarURL({ dynamic: true }))
            .setTitle("User Info")
            .setDescription(`**Tag:** ${fetching.tag}\n**ID:** ${fetching.id}\n**Bot:** ${fetching.bot ? "✅" : "❌"}\n**Joined At: <t:${Math.round(parseInt(fetching.createdTimestamp) / 1000)}:F>**`)
            .setTimestamp();
        return msg.channel.send({ embeds: [userInfo] });
    } catch (err) {
        log(err);
        return;
    }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!