mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
feat: show premium badge on system/member/group cards
This commit is contained in:
parent
59b9b6f6ec
commit
41f8beb2aa
2 changed files with 21 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<MessageComponent[]> 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<MessageComponent> 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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue