From 41f8beb2aa3a6ee71124f4348a2f55001877c467 Mon Sep 17 00:00:00 2001 From: Iris System Date: Sat, 27 Dec 2025 16:47:51 +1300 Subject: [PATCH] feat: show premium badge on system/member/group cards --- .../CommandSystem/Context/Context.cs | 4 ++-- PluralKit.Bot/Services/EmbedService.cs | 23 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/Context.cs b/PluralKit.Bot/CommandSystem/Context/Context.cs index 5e52a141..412f8cd4 100644 --- a/PluralKit.Bot/CommandSystem/Context/Context.cs +++ b/PluralKit.Bot/CommandSystem/Context/Context.cs @@ -89,9 +89,9 @@ public class Context } public string PremiumEmoji => (Config?.PremiumLifetime ?? false) - ? ($"<:lifetime_premium:{_botConfig.PremiumLifetimeEmoji}>" ?? "\u2729") + ? (_botConfig.PremiumLifetimeEmoji != null ? $"<:lifetime_premium:{_botConfig.PremiumLifetimeEmoji}>" : "\u2729") : Premium - ? ($"<:premium_subscriber:{_botConfig.PremiumSubscriberEmoji}>" ?? "\u2729") + ? (_botConfig.PremiumSubscriberEmoji != null ? $"<:premium_subscriber:{_botConfig.PremiumSubscriberEmoji}>" : "\u2729") : ""; public readonly string CommandPrefix; diff --git a/PluralKit.Bot/Services/EmbedService.cs b/PluralKit.Bot/Services/EmbedService.cs index 2dd08abf..21dd04b8 100644 --- a/PluralKit.Bot/Services/EmbedService.cs +++ b/PluralKit.Bot/Services/EmbedService.cs @@ -45,6 +45,17 @@ public class EmbedService return Task.WhenAll(ids.Select(Inner)); } + private async Task<(bool Premium, string? Emoji)> SystemHasPremium(PKSystem system) + { + var config = await _repo.GetSystemConfig(system.Id); + if (config.PremiumLifetime) + return (true, (_config.PremiumLifetimeEmoji != null ? $"<:lifetime_premium:{_config.PremiumLifetimeEmoji}>" : "\u2729")); + else if (config.PremiumUntil != null && SystemClock.Instance.GetCurrentInstant() < config.PremiumUntil!) + return (true, (_config.PremiumSubscriberEmoji != null ? $"<:premium_subscriber:{_config.PremiumSubscriberEmoji}>" : "\u2729")); + + return (false, null); + } + public async Task CreateSystemMessageComponents(Context cctx, PKSystem system, LookupContext ctx) { // Fetch/render info for all accounts simultaneously @@ -143,7 +154,9 @@ public class EmbedService }); var systemName = (cctx.Guild != null && guildSettings?.DisplayName != null) ? guildSettings?.DisplayName! : system.NameFor(ctx); - var premiumText = ""; // TODO(iris): "\n\U0001F31F *PluralKit Premium supporter!*"; + + var systemPremium = await SystemHasPremium(system); + var premiumText = systemPremium.Premium ? $"\n{systemPremium.Emoji} *PluralKit Premium supporter*" : ""; List header = [ new MessageComponent() { @@ -194,7 +207,7 @@ public class EmbedService new MessageComponent() { Type = ComponentType.Text, - Content = $"-# System ID: `{system.DisplayHid(cctx.Config)}`{cctx.PremiumEmoji}\n-# Created: {system.Created.FormatZoned(cctx.Zone)}", + Content = $"-# System ID: `{system.DisplayHid(cctx.Config)}`\n-# Created: {system.Created.FormatZoned(cctx.Zone)}", }, ], Accessory = new MessageComponent() @@ -457,6 +470,7 @@ public class EmbedService }, ]; + var systemPremium = await SystemHasPremium(system); return [ new MessageComponent() { @@ -471,7 +485,7 @@ public class EmbedService new MessageComponent() { Type = ComponentType.Text, - Content = $"-# System ID: `{system.DisplayHid(ccfg)}` \u2219 Member ID: `{member.DisplayHid(ccfg)}`{(member.MetadataPrivacy.CanAccess(ctx) ? $"\n-# Created: {member.Created.FormatZoned(zone)}" : "")}", + Content = $"-# System ID: `{system.DisplayHid(ccfg)}`{(systemPremium.Premium ? $" {systemPremium.Emoji}" : "")} \u2219 Member ID: `{member.DisplayHid(ccfg)}`{(member.MetadataPrivacy.CanAccess(ctx) ? $"\n-# Created: {member.Created.FormatZoned(zone)}" : "")}", }, ], Accessory = new MessageComponent() @@ -647,6 +661,7 @@ public class EmbedService }, ]; + var systemPremium = await SystemHasPremium(system); return [ new MessageComponent() { @@ -661,7 +676,7 @@ public class EmbedService new MessageComponent() { Type = ComponentType.Text, - Content = $"-# System ID: `{system.DisplayHid(ctx.Config)}` \u2219 Group ID: `{target.DisplayHid(ctx.Config)}`{(target.MetadataPrivacy.CanAccess(pctx) ? $"\n-# Created: {target.Created.FormatZoned(ctx.Zone)}" : "")}", + Content = $"-# System ID: `{system.DisplayHid(ctx.Config)}`{(systemPremium.Premium ? $" {systemPremium.Emoji}" : "")} \u2219 Group ID: `{target.DisplayHid(ctx.Config)}`{(target.MetadataPrivacy.CanAccess(pctx) ? $"\n-# Created: {target.Created.FormatZoned(ctx.Zone)}" : "")}", }, ], Accessory = new MessageComponent()