From 1b2d069f28734c798d39766d728176b3c4461c2a Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 25 Aug 2025 12:22:22 +1200 Subject: [PATCH] fix(bot): more null/empty-string checks in CV2 cards --- PluralKit.Bot/Services/EmbedService.cs | 34 +++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/PluralKit.Bot/Services/EmbedService.cs b/PluralKit.Bot/Services/EmbedService.cs index f991b554..d66a6b5a 100644 --- a/PluralKit.Bot/Services/EmbedService.cs +++ b/PluralKit.Bot/Services/EmbedService.cs @@ -126,7 +126,7 @@ public class EmbedService }); } - if (system.BannerPrivacy.CanAccess(ctx)) + if (system.BannerPrivacy.CanAccess(ctx) && !string.IsNullOrWhiteSpace(system.BannerImage)) descComponents.Add(new() { Type = ComponentType.MediaGallery, @@ -139,23 +139,25 @@ public class EmbedService new MessageComponent() { Type = ComponentType.Text, - Content = $"## [{systemName}](https://dash.pluralkit.me/profile/s/{system.Hid}){premiumText}", + Content = $"## [{systemName ?? $"`{system.DisplayHid(cctx.Config)}`"}](https://dash.pluralkit.me/profile/s/{system.Hid}){premiumText}", }, - new MessageComponent() + ]; + + if (!string.IsNullOrWhiteSpace(headerText)) + header.Add(new MessageComponent() { Type = ComponentType.Text, Content = headerText, - }, - ]; + }); if (cctx.Guild != null) { var guildAvatar = guildSettings.AvatarUrl.TryGetCleanCdnUrl(); - if (guildAvatar != null) + if (!string.IsNullOrWhiteSpace(guildAvatar)) avatar = guildAvatar; } - if (avatar != null) + if (!string.IsNullOrWhiteSpace(avatar)) header = [ new MessageComponent() { @@ -304,14 +306,16 @@ public class EmbedService Type = ComponentType.Text, Content = $"## [{name}](https://dash.pluralkit.me/profile/m/{member.Hid}){(systemName != null ? $" ({systemName})" : "")}", }, - new MessageComponent() + ]; + + if (!string.IsNullOrWhiteSpace(headerText)) + header.Add(new MessageComponent() { Type = ComponentType.Text, Content = headerText, - }, - ]; + }); - if (avatar != null) + if (!string.IsNullOrWhiteSpace(avatar)) header = [ new MessageComponent() { @@ -476,12 +480,14 @@ public class EmbedService Type = ComponentType.Text, Content = $"## [{name}](https://dash.pluralkit.me/profile/g/{target.Hid}){(systemName != null ? $" ({systemName})" : "")}", }, - new MessageComponent() + ]; + + if (!string.IsNullOrWhiteSpace(headerText)) + header.Add(new MessageComponent() { Type = ComponentType.Text, Content = headerText, - }, - ]; + }); if (target.IconFor(pctx) is { } icon) header = [