• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

25
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.

about 1 month 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)
about 1 month ago · Juan Pablo Isaza Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

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