Example #1
0
        public async Task RandomColorAsync()
        {
            var color          = Color.Random;
            var colorImagePath = _colorService.GetColorImage(color.ToString());

            using (var colorImage = LocalAttachment.File(colorImagePath, "colorImage.png"))
            {
                var eb = new LocalEmbed()
                         .WithColor(color)
                         .WithDescription($"Hex: {color.ToString()}\nRGB: {color.R} {color.G} {color.B}")
                         .WithImageUrl("attachment://colorImage.png");

                var mb = new LocalMessage()
                         .WithAttachments(colorImage)
                         .WithEmbeds(eb);

                await Response(mb);
            }

            File.Delete(colorImagePath);
        }
Example #2
0
        public async Task SearchColorAsync([Description("The hex color to retrieve info about")] Color color)
        {
            var result = await _colorService.GetColorInfo(color.ToString().Substring(1));

            var colorImagePath = _colorService.GetColorImage(color.ToString());

            using (var colorImage = LocalAttachment.File(colorImagePath, "colorImage.png"))
            {
                var eb = new LocalEmbed()
                         .WithTitle(result.Name.Value)
                         .WithColor(color)
                         .WithImageUrl("attachment://colorImage.png");

                if (result.Name.ExactMatchName)
                {
                    eb.AddField("Hex value", result.Hex.Value);
                }
                else
                {
                    eb.AddField("Closest Match Hex", result.Name.ClosestNamedHex);
                }

                eb.AddField("RGB", result.Rgb.Value)
                .AddField("HSL", result.Hsl.Value)
                .AddField("HSV", result.Hsv.Value)
                .AddField("CMYK", result.Cmyk.Value);

                var mb = new LocalMessage()
                         .WithAttachments(colorImage)
                         .WithEmbeds(eb);

                await Response(mb);
            }

            File.Delete(colorImagePath);
        }