Add color to frontpercent embed (#307)

* Add color to frontpercent embed

* don't pass color as a separate argument

Co-authored-by: Astrid <mail+github@astr.cc>
This commit is contained in:
Spectralitree 2021-05-07 10:40:57 +02:00 committed by GitHub
parent 411cbdcd58
commit b1c7fbd2df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -323,13 +323,29 @@ namespace PluralKit.Bot {
public Task<Embed> CreateFrontPercentEmbed(FrontBreakdown breakdown, PKSystem system, PKGroup group, DateTimeZone tz, LookupContext ctx, string embedTitle, bool ignoreNoFronters)
{
string color = system.Color;
if (group != null)
{
color = group.Color;
}
uint embedColor;
try
{
embedColor = color?.ToDiscordColor() ?? DiscordUtils.Gray;
}
catch (ArgumentException)
{
embedColor = DiscordUtils.Gray;
}
var actualPeriod = breakdown.RangeEnd - breakdown.RangeStart;
// this is kinda messy?
var hasFrontersPeriod = Duration.FromTicks(breakdown.MemberSwitchDurations.Values.ToList().Sum(i => i.TotalTicks));
var eb = new EmbedBuilder()
.Title(embedTitle)
.Color(DiscordUtils.Gray)
.Color(embedColor)
.Footer(new($"Since {breakdown.RangeStart.FormatZoned(tz)} ({actualPeriod.FormatDuration()} ago)"));
var maxEntriesToDisplay = 24; // max 25 fields allowed in embed - reserve 1 for "others"