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:
parent
411cbdcd58
commit
b1c7fbd2df
@ -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)
|
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;
|
var actualPeriod = breakdown.RangeEnd - breakdown.RangeStart;
|
||||||
// this is kinda messy?
|
// this is kinda messy?
|
||||||
var hasFrontersPeriod = Duration.FromTicks(breakdown.MemberSwitchDurations.Values.ToList().Sum(i => i.TotalTicks));
|
var hasFrontersPeriod = Duration.FromTicks(breakdown.MemberSwitchDurations.Values.ToList().Sum(i => i.TotalTicks));
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Title(embedTitle)
|
.Title(embedTitle)
|
||||||
.Color(DiscordUtils.Gray)
|
.Color(embedColor)
|
||||||
.Footer(new($"Since {breakdown.RangeStart.FormatZoned(tz)} ({actualPeriod.FormatDuration()} ago)"));
|
.Footer(new($"Since {breakdown.RangeStart.FormatZoned(tz)} ({actualPeriod.FormatDuration()} ago)"));
|
||||||
var maxEntriesToDisplay = 24; // max 25 fields allowed in embed - reserve 1 for "others"
|
var maxEntriesToDisplay = 24; // max 25 fields allowed in embed - reserve 1 for "others"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user