discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.5k stars 3.97k forks source link

user.accentColor / member.displayColor / member.displayHexColor Null on Nitro #9841

Closed Taelyn closed 1 year ago

Taelyn commented 1 year ago

Which package is this bug report for?

discord.js

Issue description

user.accentColor member.displayColor member.displayHexColor

Seems to be null when user / member has nitro subscription I seem to only get user.accentColor working on a user without Nitro

Code sample

const user = await interaction.user.fetch();
console.log(user.accentColor);

const member = await interaction.member.fetch();
console.log(member.displayColor);

Versions

discord.js v14.13.0 Typescript v5.2.2 Node LTS v18.17.1

Issue priority

Low (slightly annoying)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction, ThreadMember

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildModeration, GuildEmojisAndStickers, GuildIntegrations, GuildWebhooks, GuildInvites, GuildVoiceStates, GuildPresences, GuildMessages, GuildMessageReactions, GuildMessageTyping, DirectMessages, MessageContent, GuildScheduledEvents, AutoModerationConfiguration, AutoModerationExecution

I have tested this issue on a development release

No response

Jiralite commented 1 year ago

You don't appear to be force-fetching. Force-fetching is required for the property to be present or updated as documented.

Taelyn commented 1 year ago

As i said it does not work ;) force or not, it does not give the data on a Nitro User Nitro users have 2 color options on there profile instead of one

perhaps read first before you comment.

Jiralite commented 1 year ago

I cannot reproduce this.

Without knowing who you fetched, we cannot confirm either. Supply ids. I can only speculate otherwise: you are correctly seeing the properties but believe otherwise or you are misunderstanding what these properties do.

Taelyn commented 1 year ago

Iam perfectly aware what the properties do. If you look in your own code:

  get displayColor() {
    return this.roles.color?.color ?? 0;
  }

  get displayHexColor() {
    return this.roles.color?.hexColor ?? '#000000';
  }

GuildMember.displayColor and HexColor is giveing the role color of the role that the member has. So your documentation is wrong or you asigned the wrong code. Since neither the 2 properties have anywhere explained it gives a role color

        const _member = await interaction.member.fetch(true);
        console.log("_member.displayColor: " + _member.displayColor);
        console.log("_member.displayHexColor: " + _member.displayHexColor);

        const _user = await interaction.user.fetch(true);
        console.log("_user.accentColor: " + _user.accentColor);

on a non nitro user:

2023-09-19 10_15_31-#general _ Taelyn Bot - Discord 2023-09-19 10_16_09-TaelynBot - Microsoft Visual Studio

As you see it works, it outputs the accentColor the user has, Dark Green and displayColor, displayHexColor output the Role color what is yellow

on a Nitro User: 2023-09-19 10_18_53-taelynbotcore 2023-09-19 10_19_01-#general _ Taelyn Bot - Discord

accentColor is Null. Since my profile has 2 colors due to nitro. displayColor and displayHexColor give again the role color what is yellow

Profile 1 Id : 1114640765050683575 Profile 2 Id: 317550181098717185

I hope its clear enough this way

Jiralite commented 1 year ago

These properties are working as intended!

Since updates to guild member profiles, I can see a change in documentation could be made to alleviate the confusion between the colours in a profile and the role colour, but there is no issue in code here.

almostSouji commented 1 year ago

I looked into the accent color a little bit and the behavior we see in the library is consistent with the behavior of the API (which is wholly scuffed), so here is the current theory:

fancy profiles := two colors, banner

This would suggest, that you never set a manual, solid, banner (aka accent) color before you got access to fancy profiles, but instead relied on the auto-set one based on your avatar, hence the value is null.

The other person (used as non-nitro user in your example) clearly has one set, their avatar is blue and their banner is solid green. (Unless discords banner color determining algorithm is really, really horrible)

[!NOTE]
TL;DR: accent color is not fancy profile 2 colors, nor are fancy profile colors exposed anywhere, neither for global nor guild based profiles

Taelyn commented 1 year ago

Thanks both!