Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a (Discord)Color using a string #2979

Merged
merged 4 commits into from
Aug 14, 2024

Conversation

Adrigorithm
Copy link
Contributor

Description

It allows for Colours to be created from strings using constructor overloading. Please accept my first PRussy to Discord.Net :^)

Changes

  • new constructor taking a string (and an enum for possible future color formats))
  • tests for this constructor

@Misha-133
Copy link
Member

Since it's parsing a string value, the logic should go into a static Parse method
Could you do that? And also make a bool TryParse() one please

@Adrigorithm
Copy link
Contributor Author

Adrigorithm commented Aug 11, 2024

Added the bitmasking and uh the if (rawValue.StartsWith("0x")) was needed because people can actually create hex codes that include leading 0's :(

src/Discord.Net.Core/Entities/Roles/Color.cs Outdated Show resolved Hide resolved
src/Discord.Net.Core/Entities/Roles/Color.cs Outdated Show resolved Hide resolved
@Misha-133 Misha-133 enabled auto-merge (squash) August 14, 2024 19:55
@Misha-133 Misha-133 merged commit bc84b94 into discord-net:dev Aug 14, 2024
2 checks passed
@itslychee
Copy link

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants