Class RoleColors

java.lang.Object
net.dv8tion.jda.api.entities.RoleColors
All Implemented Interfaces:
SerializableData

public class RoleColors extends Object implements SerializableData
The colors of a Role.

Roles can have up to three color components, and the appearance changes depending on how many components are configured.

  • If a role has no configured colors, then it uses the default color of the current display theme in the client, which contrasts with the theme's background. (See isDefault())
  • If a role only has a primary color, it uses a solid color style. (See isSolid())
  • If a role has two configured colors with getPrimary() and getSecondary(), then it uses a gradient of the two colors. (See isGradient())
  • If a role has three configured colors, it uses a holographic style instead. (See isHolographic())
  • Field Details

    • DEFAULT_HOLOGRAPHIC

      public static final RoleColors DEFAULT_HOLOGRAPHIC
      Sentinel values used by Discord to indicate holographic style.
      See Also:
    • DEFAULT

      public static final RoleColors DEFAULT
      The default colors used by a role. The display color is determined by the selected theme on each client.
      See Also:
  • Constructor Details

    • RoleColors

      public RoleColors(int primary, int secondary, int tertiary)
  • Method Details

    • isDefault

      public boolean isDefault()
      Whether this role uses the default colors, which is determined by the client theme.
      Returns:
      True, if the primary color is Role.DEFAULT_COLOR_RAW
    • isSolid

      public boolean isSolid()
      Whether this role uses solid color style.
      Returns:
      True if only a primary color is configured.
    • isGradient

      public boolean isGradient()
      Whether this role uses gradient style.
      Returns:
      True if a secondary color is configured but no tertiary color.
    • isHolographic

      public boolean isHolographic()
      Whether this role uses holographic style.
      Returns:
      True, if the colors match DEFAULT_HOLOGRAPHIC
    • getPrimary

      @Nullable public Color getPrimary()
      The primary color component of the role.
      Returns:
      Primary Color or null if the default color is used
      See Also:
    • getPrimaryRaw

      public int getPrimaryRaw()
      The primary color component of the role.
      Returns:
      Primary Color as a raw RGB value or Role.DEFAULT_COLOR_RAW if the default color is used
      See Also:
    • getSecondary

      @Nullable public Color getSecondary()
      The secondary color component of the role.

      This is only set for roles with gradient colors and only applied if the Guild has the ENHANCED_ROLE_COLORS feature enabled.

      Returns:
      Secondary Color or null if this role has no gradient color
      See Also:
    • getSecondaryRaw

      public int getSecondaryRaw()
      The secondary color component of the role.

      This is only set for roles with gradient colors and only applied if the Guild has the ENHANCED_ROLE_COLORS feature enabled.

      Returns:
      Secondary Color as a raw RGB value or Role.DEFAULT_COLOR_RAW if this role has no gradient color
      See Also:
    • getTertiary

      @Nullable public Color getTertiary()
      The tertiary color component of the role.

      This is only set for roles with holographic style and only applied if the Guild has the ENHANCED_ROLE_COLORS feature enabled.

      Returns:
      Tertiary Color or null if this role has no holographic style
      See Also:
    • getTertiaryRaw

      public int getTertiaryRaw()
      The tertiary color component of the role.

      This is only set for roles with holographic style and only applied if the Guild has the ENHANCED_ROLE_COLORS feature enabled.

      Returns:
      Tertiary Color as a raw RGB value or Role.DEFAULT_COLOR_RAW if this role has no holographic style
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toData

      @Nonnull public DataObject toData()
      Description copied from interface: SerializableData
      Serialized DataObject for this object.
      Specified by:
      toData in interface SerializableData
      Returns:
      DataObject