/// <summary> Shows hex color. </summary> public static async Task <Embed> GetRgbColorAsync(string hexColor) { if (hexColor.Contains('#')) { hexColor = hexColor.Replace("#", ""); } try { var response = await HttpHelper.HttpClient.GetAsync($"https://some-random-api.ml/canvas/rgb?hex={hexColor}"); var jsonString = await response.Content.ReadAsStringAsync(); var jsonParsed = JObject.Parse(jsonString); var r = (int)jsonParsed["r"]; var g = (int)jsonParsed["g"]; var b = (int)jsonParsed["b"]; var imageUrl = $"https://some-random-api.ml/canvas/colorviewer?hex={hexColor}"; return(CustomFormats.CreateColorEmbed(imageUrl, r, g, b, hexColor)); } catch (Exception) { return(CustomFormats.CreateErrorEmbed("**Color not found!**")); } }
/// <summary> Shows hex color. </summary> public static async Task <Embed> GetHexColorAsync(int r, int g, int b) { try { var response = await HttpHelper.HttpClient.GetAsync($"https://some-random-api.ml/canvas/hex?rgb={r},{g},{b}"); var jsonString = await response.Content.ReadAsStringAsync(); var jsonParsed = JObject.Parse(jsonString); var hex = (string)jsonParsed["hex"]; hex = hex?.Replace("#", ""); var imageUrl = $"https://some-random-api.ml/canvas/colorviewer?hex={hex}"; return(CustomFormats.CreateColorEmbed(imageUrl, r, g, b, hex)); } catch (Exception) { return(CustomFormats.CreateErrorEmbed("**Color not found!**")); } }