1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 18:53:30 +00:00

discord: Add Color.String

This commit is contained in:
diamondburned 2022-03-31 11:46:45 -07:00
parent eae129c928
commit 0cc36ee51e
No known key found for this signature in database
GPG key ID: D78C4471CE776659

View file

@ -38,6 +38,12 @@ func (c Color) RGB() (uint8, uint8, uint8) {
return r, g, b
}
// String returns the Color in hexadecimal (#FFFFFF) format.
func (c Color) String() string {
r, g, b := c.RGB()
return fmt.Sprintf("#%02X%02X%02X", r, g, b)
}
func (c Color) MarshalJSON() ([]byte, error) {
if c < 0 {
return []byte("null"), nil