• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

323
Views
Getting 'undefined' .hexAccentColor value even when force fetching user?

I'm trying to create an info command that pulls the specified users info. As per the discord.js docs, I'm force fetching the specified user to get the .hexAccentColor. The user I'm fetching does have an accent color, yet I get undefined as the value every time I try to get it. Here is my code:

const user = await client.users.fetch(
      interaction.options.getUser("user"),
      false,
      true
    );
    const embed = new MessageEmbed()
      .setColor(`${user.hexAccentColor}`)
      .setTitle(`User info for ${user.username}`)
      .addFields(
        { name: "User Tag:", value: `${user.tag}`, inline: true },
        { name: "User ID:", value: `${user.id}`, inline: true },
        { name: "Bot Status:", value: `${user.bot}`, inline: true },
        {
          name: "Account Creation Date:",
          value: `${user.createdAt}`,
          inline: false,
        }
      )
      .setImage(`${user.displayAvatarURL()}`);

All the other information is being passed correctly, it's just the color values that I'm getting undefined for.

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You aren't actually force fetching. The arguments aren't correct (see UserManager#fetch()). Here's how to force fetch a user

const user = await client.users.fetch(
    interaction.options.getUser("user"),
    {
      force: true
    }
)

But rather than fetching like this, you could do a simple User#fetch(), since interaction.options.getUser returns a User instance

const user = await interaction.options.getUser("user").fetch(true)
almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error