diff --git a/PluralKit.Bot/Commands/GroupMember.cs b/PluralKit.Bot/Commands/GroupMember.cs index ee9656bc..c2569d43 100644 --- a/PluralKit.Bot/Commands/GroupMember.cs +++ b/PluralKit.Bot/Commands/GroupMember.cs @@ -66,7 +66,7 @@ public class GroupMember if (groups.Count == 0) description = "This member has no groups."; else - description = string.Join("\n", groups.Select(g => $"[`{g.DisplayHid(ctx.Config)}`] **{g.DisplayName ?? g.Name}**")); + description = string.Join("\n", groups.Select(g => $"[`{g.DisplayHid(ctx.Config, isList: true)}`] **{g.DisplayName ?? g.Name}**")); if (pctx == LookupContext.ByOwner) { diff --git a/PluralKit.Bot/Commands/Lists/ContextListExt.cs b/PluralKit.Bot/Commands/Lists/ContextListExt.cs index 45cad921..d2f1272f 100644 --- a/PluralKit.Bot/Commands/Lists/ContextListExt.cs +++ b/PluralKit.Bot/Commands/Lists/ContextListExt.cs @@ -128,9 +128,7 @@ public static class ContextListExt // so run it through a helper that "makes it work" :) eb.WithSimpleLineContent(page.Select(m => { - var leftpad = m.Hid.Length == 5 && ctx.Config?.HidListPadding == SystemConfig.HidPadFormat.Left ? " " : ""; - var rightpad = m.Hid.Length == 5 && ctx.Config?.HidListPadding == SystemConfig.HidPadFormat.Right ? " " : ""; - var ret = $"[`{leftpad}{m.DisplayHid(ctx.Config)}{rightpad}`] **{m.NameFor(ctx)}** "; + var ret = $"[`{m.DisplayHid(ctx.Config, isList: true)}`] **{m.NameFor(ctx)}** "; if (opts.IncludeMessageCount && m.MessageCountFor(lookupCtx) is { } count) ret += $"({count} messages)"; @@ -240,9 +238,7 @@ public static class ContextListExt // so run it through a helper that "makes it work" :) eb.WithSimpleLineContent(page.Select(g => { - var leftpad = g.Hid.Length == 5 && ctx.Config?.HidListPadding == SystemConfig.HidPadFormat.Left ? " " : ""; - var rightpad = g.Hid.Length == 5 && ctx.Config?.HidListPadding == SystemConfig.HidPadFormat.Right ? " " : ""; - var ret = $"[`{leftpad}{g.DisplayHid(ctx.Config)}{rightpad}`] **{g.NameFor(ctx)}** "; + var ret = $"[`{g.DisplayHid(ctx.Config, isList: true)}`] **{g.NameFor(ctx)}** "; switch (opts.SortProperty) { diff --git a/PluralKit.Bot/Services/EmbedService.cs b/PluralKit.Bot/Services/EmbedService.cs index be2e6b41..fe4e9c0c 100644 --- a/PluralKit.Bot/Services/EmbedService.cs +++ b/PluralKit.Bot/Services/EmbedService.cs @@ -255,7 +255,7 @@ public class EmbedService // More than 5 groups show in "compact" format without ID var content = groups.Count > 5 ? string.Join(", ", groups.Select(g => g.DisplayName ?? g.Name)) - : string.Join("\n", groups.Select(g => $"[`{g.DisplayHid(ccfg)}`] **{g.DisplayName ?? g.Name}**")); + : string.Join("\n", groups.Select(g => $"[`{g.DisplayHid(ccfg, isList: true)}`] **{g.DisplayName ?? g.Name}**")); eb.Field(new Embed.Field($"Groups ({groups.Count})", content.Truncate(1000))); } diff --git a/PluralKit.Bot/Utils/ModelUtils.cs b/PluralKit.Bot/Utils/ModelUtils.cs index 2576c77a..513f4e1d 100644 --- a/PluralKit.Bot/Utils/ModelUtils.cs +++ b/PluralKit.Bot/Utils/ModelUtils.cs @@ -28,14 +28,15 @@ public static class ModelUtils public static string Reference(this PKGroup group, Context ctx) => EntityReference(group.DisplayHid(ctx.Config), group.NameFor(ctx)); - public static string DisplayHid(this PKSystem system, SystemConfig? cfg = null) => HidTransform(system.Hid, cfg); - public static string DisplayHid(this PKGroup group, SystemConfig? cfg = null) => HidTransform(group.Hid, cfg); - public static string DisplayHid(this PKMember member, SystemConfig? cfg = null) => HidTransform(member.Hid, cfg); - private static string HidTransform(string hid, SystemConfig? cfg = null) => + public static string DisplayHid(this PKSystem system, SystemConfig? cfg = null, bool isList = false) => HidTransform(system.Hid, cfg, isList); + public static string DisplayHid(this PKGroup group, SystemConfig? cfg = null, bool isList = false) => HidTransform(group.Hid, cfg, isList); + public static string DisplayHid(this PKMember member, SystemConfig? cfg = null, bool isList = false) => HidTransform(member.Hid, cfg, isList); + private static string HidTransform(string hid, SystemConfig? cfg = null, bool isList = false) => HidUtils.HidTransform( hid, cfg != null && cfg.HidDisplaySplit, - cfg != null && cfg.HidDisplayCaps + cfg != null && cfg.HidDisplayCaps, + isList ? (cfg?.HidListPadding ?? SystemConfig.HidPadFormat.None) : SystemConfig.HidPadFormat.None // padding only on lists ); private static string EntityReference(string hid, string name) diff --git a/PluralKit.Core/Database/Utils/HidUtils.cs b/PluralKit.Core/Database/Utils/HidUtils.cs index 15945226..ecc79212 100644 --- a/PluralKit.Core/Database/Utils/HidUtils.cs +++ b/PluralKit.Core/Database/Utils/HidUtils.cs @@ -22,7 +22,7 @@ public static class HidUtils return hid != null; } - public static string HidTransform(string input, bool split, bool caps) + public static string HidTransform(string input, bool split, bool caps, SystemConfig.HidPadFormat pad) { if (split && input.Length > 5) { @@ -33,6 +33,19 @@ public static class HidUtils if (caps) input = input.ToUpper(); + if (input.Length == 5) + switch (pad) + { + case SystemConfig.HidPadFormat.Left: + input = " " + input; + if (split) input = " " + input; + break; + case SystemConfig.HidPadFormat.Right: + input = input + " "; + if (split) input = input + " "; + break; + } + return input; } } \ No newline at end of file