Fix spurious empty-string-description errors
This commit is contained in:
parent
7a1aaf6dbd
commit
48342a2890
@ -115,14 +115,14 @@ namespace PluralKit.Bot {
|
||||
|
||||
if (avatar != null) eb.WithThumbnailUrl(avatar);
|
||||
|
||||
if (member.DisplayName != null) eb.AddField("Display Name", member.DisplayName.Truncate(1024), true);
|
||||
if (!member.DisplayName.EmptyOrNull()) eb.AddField("Display Name", member.DisplayName.Truncate(1024), true);
|
||||
if (guild != null && guildDisplayName != null) eb.AddField($"Server Nickname (for {guild.Name})", guildDisplayName.Truncate(1024), true);
|
||||
if (member.Birthday != null && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Birthdate", member.BirthdayString, true);
|
||||
if (member.Pronouns != null && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Pronouns", member.Pronouns.Truncate(1024), true);
|
||||
if (!member.Pronouns.EmptyOrNull() && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Pronouns", member.Pronouns.Truncate(1024), true);
|
||||
if (messageCount > 0 && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Message Count", messageCount, true);
|
||||
if (member.HasProxyTags) eb.AddField("Proxy Tags", string.Join('\n', proxyTagsStr).Truncate(1024), true);
|
||||
if (member.Color != null && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Color", $"#{member.Color}", true);
|
||||
if (member.Description != null && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Description", member.Description, false);
|
||||
if (!member.Color.EmptyOrNull() && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Color", $"#{member.Color}", true);
|
||||
if (!member.Description.EmptyOrNull() && member.MemberPrivacy.CanAccess(ctx)) eb.AddField("Description", member.Description, false);
|
||||
|
||||
return eb.Build();
|
||||
}
|
||||
|
@ -53,5 +53,12 @@ namespace PluralKit.Core
|
||||
if (input.Trim().Length == 0) return null;
|
||||
return input;
|
||||
}
|
||||
|
||||
public static bool EmptyOrNull(this string input)
|
||||
{
|
||||
if (input == null) return true;
|
||||
if (input.Trim().Length == 0) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user