From 55ebeaf45fe0e8a137571d783cfa41e2fdc348d7 Mon Sep 17 00:00:00 2001 From: "diamondburned (Forefront)" Date: Sun, 23 Feb 2020 10:11:10 -0800 Subject: [PATCH] Discord: Added a convenient RGB function for Color --- discord/message_embed.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/discord/message_embed.go b/discord/message_embed.go index 0829617..0544953 100644 --- a/discord/message_embed.go +++ b/discord/message_embed.go @@ -14,6 +14,19 @@ func (c Color) Int() int { return int(c) } +// RGB splits Color into red, green, and blue. The maximum value is 255. +func (c Color) RGB() (uint8, uint8, uint8) { + var ( + color = c.Uint32() + + r = uint8((color >> 16) & 255) + g = uint8((color >> 8) & 255) + b = uint8(color & 255) + ) + + return r, g, b +} + type Embed struct { Title string `json:"title,omitempty"` Type EmbedType `json:"type,omitempty"`