mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-15 02:00:09 +00:00
fix(bot): default embed colour should be null
This commit is contained in:
parent
843275a3ac
commit
7ef1dce0a5
2 changed files with 6 additions and 52 deletions
|
|
@ -56,22 +56,11 @@ public class EmbedService
|
||||||
|
|
||||||
var memberCount = await _repo.GetSystemMemberCount(system.Id, countctx == LookupContext.ByOwner ? null : PrivacyLevel.Public);
|
var memberCount = await _repo.GetSystemMemberCount(system.Id, countctx == LookupContext.ByOwner ? null : PrivacyLevel.Public);
|
||||||
|
|
||||||
uint color;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
color = system.Color?.ToDiscordColor() ?? DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
// There's no API for system colors yet, but defaulting to a blank color in advance can't be a bad idea
|
|
||||||
color = DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Title(system.NameFor(ctx))
|
.Title(system.NameFor(ctx))
|
||||||
.Footer(new Embed.EmbedFooter(
|
.Footer(new Embed.EmbedFooter(
|
||||||
$"System ID: {system.DisplayHid(cctx.Config)} | Created on {system.Created.FormatZoned(cctx.Zone)}"))
|
$"System ID: {system.DisplayHid(cctx.Config)} | Created on {system.Created.FormatZoned(cctx.Zone)}"))
|
||||||
.Color(color)
|
.Color(system.Color?.ToDiscordColor())
|
||||||
.Url($"https://dash.pluralkit.me/profile/s/{system.Hid}");
|
.Url($"https://dash.pluralkit.me/profile/s/{system.Hid}");
|
||||||
|
|
||||||
var avatar = system.AvatarFor(ctx);
|
var avatar = system.AvatarFor(ctx);
|
||||||
|
|
@ -188,19 +177,6 @@ public class EmbedService
|
||||||
else
|
else
|
||||||
name = $"{name}";
|
name = $"{name}";
|
||||||
|
|
||||||
uint color;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
color = member.Color?.ToDiscordColor() ?? DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
// Bad API use can cause an invalid color string
|
|
||||||
// this is now fixed in the API, but might still have some remnants in the database
|
|
||||||
// so we just default to a blank color, yolo
|
|
||||||
color = DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
var guildSettings = guild != null ? await _repo.GetMemberGuild(guild.Id, member.Id) : null;
|
var guildSettings = guild != null ? await _repo.GetMemberGuild(guild.Id, member.Id) : null;
|
||||||
var guildDisplayName = guildSettings?.DisplayName;
|
var guildDisplayName = guildSettings?.DisplayName;
|
||||||
var webhook_avatar = guildSettings?.AvatarUrl ?? member.WebhookAvatarFor(ctx) ?? member.AvatarFor(ctx);
|
var webhook_avatar = guildSettings?.AvatarUrl ?? member.WebhookAvatarFor(ctx) ?? member.AvatarFor(ctx);
|
||||||
|
|
@ -213,8 +189,8 @@ public class EmbedService
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Author(new Embed.EmbedAuthor(name, IconUrl: webhook_avatar.TryGetCleanCdnUrl(), Url: $"https://dash.pluralkit.me/profile/m/{member.Hid}"))
|
.Author(new Embed.EmbedAuthor(name, IconUrl: webhook_avatar.TryGetCleanCdnUrl(), Url: $"https://dash.pluralkit.me/profile/m/{member.Hid}"))
|
||||||
// .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : DiscordUtils.Gray)
|
// .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : null)
|
||||||
.Color(color)
|
.Color(member.Color?.ToDiscordColor())
|
||||||
.Footer(new Embed.EmbedFooter(
|
.Footer(new Embed.EmbedFooter(
|
||||||
$"System ID: {system.DisplayHid(ccfg)} | Member ID: {member.DisplayHid(ccfg)} {(member.MetadataPrivacy.CanAccess(ctx) ? $"| Created on {member.Created.FormatZoned(zone)}" : "")}"));
|
$"System ID: {system.DisplayHid(ccfg)} | Member ID: {member.DisplayHid(ccfg)} {(member.MetadataPrivacy.CanAccess(ctx) ? $"| Created on {member.Created.FormatZoned(zone)}" : "")}"));
|
||||||
|
|
||||||
|
|
@ -289,20 +265,9 @@ public class EmbedService
|
||||||
else
|
else
|
||||||
nameField = $"{nameField} ({system.Name})";
|
nameField = $"{nameField} ({system.Name})";
|
||||||
|
|
||||||
uint color;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
color = target.Color?.ToDiscordColor() ?? DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
// There's no API for group colors yet, but defaulting to a blank color regardless
|
|
||||||
color = DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Author(new Embed.EmbedAuthor(nameField, IconUrl: target.IconFor(pctx), Url: $"https://dash.pluralkit.me/profile/g/{target.Hid}"))
|
.Author(new Embed.EmbedAuthor(nameField, IconUrl: target.IconFor(pctx), Url: $"https://dash.pluralkit.me/profile/g/{target.Hid}"))
|
||||||
.Color(color);
|
.Color(target.Color?.ToDiscordColor());
|
||||||
|
|
||||||
eb.Footer(new Embed.EmbedFooter($"System ID: {system.DisplayHid(ctx.Config)} | Group ID: {target.DisplayHid(ctx.Config)}{(target.MetadataPrivacy.CanAccess(pctx) ? $" | Created on {target.Created.FormatZoned(ctx.Zone)}" : "")}"));
|
eb.Footer(new Embed.EmbedFooter($"System ID: {system.DisplayHid(ctx.Config)} | Group ID: {target.DisplayHid(ctx.Config)}{(target.MetadataPrivacy.CanAccess(pctx) ? $" | Created on {target.Created.FormatZoned(ctx.Zone)}" : "")}"));
|
||||||
|
|
||||||
|
|
@ -362,7 +327,7 @@ public class EmbedService
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EmbedBuilder()
|
return new EmbedBuilder()
|
||||||
.Color(members.FirstOrDefault()?.Color?.ToDiscordColor() ?? DiscordUtils.Gray)
|
.Color(members.FirstOrDefault()?.Color?.ToDiscordColor())
|
||||||
.Field(new Embed.Field($"Current {"fronter".ToQuantity(members.Count, ShowQuantityAs.None)}", memberStr))
|
.Field(new Embed.Field($"Current {"fronter".ToQuantity(members.Count, ShowQuantityAs.None)}", memberStr))
|
||||||
.Field(new Embed.Field("Since",
|
.Field(new Embed.Field("Since",
|
||||||
$"{sw.Timestamp.FormatZoned(zone)} ({timeSinceSwitch.FormatDuration()} ago)"))
|
$"{sw.Timestamp.FormatZoned(zone)} ({timeSinceSwitch.FormatDuration()} ago)"))
|
||||||
|
|
@ -461,19 +426,9 @@ public class EmbedService
|
||||||
var color = system.Color;
|
var color = system.Color;
|
||||||
if (group != null) color = group.Color;
|
if (group != null) color = group.Color;
|
||||||
|
|
||||||
uint embedColor;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
embedColor = color?.ToDiscordColor() ?? DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
embedColor = DiscordUtils.Gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Title(embedTitle)
|
.Title(embedTitle)
|
||||||
.Color(embedColor);
|
.Color(color?.ToDiscordColor());
|
||||||
|
|
||||||
var footer =
|
var footer =
|
||||||
$"Since {breakdown.RangeStart.FormatZoned(tz)} ({(breakdown.RangeEnd - breakdown.RangeStart).FormatDuration()} ago)";
|
$"Since {breakdown.RangeStart.FormatZoned(tz)} ({(breakdown.RangeEnd - breakdown.RangeStart).FormatDuration()} ago)";
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ public static class DiscordUtils
|
||||||
public const uint Blue = 0x1f99d8;
|
public const uint Blue = 0x1f99d8;
|
||||||
public const uint Green = 0x00cc78;
|
public const uint Green = 0x00cc78;
|
||||||
public const uint Red = 0xef4b3d;
|
public const uint Red = 0xef4b3d;
|
||||||
public const uint Gray = 0x979c9f;
|
|
||||||
|
|
||||||
private static readonly Regex USER_MENTION = new("<@!?(\\d{17,19})>");
|
private static readonly Regex USER_MENTION = new("<@!?(\\d{17,19})>");
|
||||||
private static readonly Regex ROLE_MENTION = new("<@&(\\d{17,19})>");
|
private static readonly Regex ROLE_MENTION = new("<@&(\\d{17,19})>");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue