question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How should Colors respect Discord's Inconsistencies?

See original GitHub issue

The behavior of default colors is now inconsistent - we need to ensure that the library respects this.

image

For roles, a color value of 0 implies to use the default color - this should line up with our current Color structure’s Default property.

For embeds, a color value of 0 implies to use black - this does not line up with our current Color structure’s Default property. To use the default color, the color field needs to be omitted from the JSON payload.

Our Embed Builder already supports omitting the color field - an embed’s Color property is of type Color?. At this point, we just need to make it clear that using Color.Default in an Embed will not actually yield the default color, but will instead produce a black embed.

This should be able to be fixed pretty easily with a Roslyn Analyzer and a documentation string on Color.Default - however, both Analyzers and Documentation are opt-in and not necessarily visible to the user when writing or reading code.

Alternatively, Color.Default could be renamed to Color.RoleDefault, though this may make it confusing to see what should then be used to create a default color in an embed.

Color.Default could also be split between Color.RoleDefault and Color.EmbedDefault, though this does not sound nice in naming, and would require modifying the Color structure to add a boolean or other marker to indicate that the color should actually be null.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Joe4evrcommented, Jan 10, 2018
0reactions
FiniteRealitycommented, Jan 10, 2018

A simple solution which wouldn’t require much effort would be to include a private bool member, which would default to false. Then, in a non-default ctor we’d initialize it to true. For example:

struct Color
{
    public static readonly Color Default
        => default(Color);

    public Color(uint @value)
    {
        _value = @value;
        _initialized = true;
    }

    private bool _initialized;
    private uint _value;

    public uint RawValue
    {
        get { return _value; }
        set { _value = value; _initialized = true; }
    }
}

This way, we can implement something like a GetColorOrDefault method, which returns RawValue if the color is initialized, or a default value if it isn’t.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does anyone think Discord is going to acknowledge the ...
Does anyone think Discord is going to acknowledge the harm they're doing to color-sensitive and visually-impaired people alike? Title. I have ...
Read more >
How do people add a yellow highlighter after pinging ...
Can I add someone on Discord using just their ID number? My friend wrote down her Discord ... What do the multiple colors...
Read more >
Discords? - WetCanvas: Online Living for Artists
Perhaps a triad like yellow/blue-violet/red. All the colors in your pix will be some mixture of these three hues; with perhaps white or...
Read more >
How to Change Name Color in Discord Based on Roles
If you have multiple discord roles with different color codes, then your username will get the color of the highest role. Note that...
Read more >
303: Facilitating Positive Environments
Your members are all humans, all community members, all people that deserve respect and deserve to be welcomed. Establishing Community Boundaries in Moderation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found