diff --git a/PluralKit.Bot/Commands/Lists/ContextListExt.cs b/PluralKit.Bot/Commands/Lists/ContextListExt.cs index 1c23cc40..15257218 100644 --- a/PluralKit.Bot/Commands/Lists/ContextListExt.cs +++ b/PluralKit.Bot/Commands/Lists/ContextListExt.cs @@ -127,11 +127,14 @@ public static class ContextListExt void ShortRenderer(EmbedBuilder eb, IEnumerable page) { + // if there are both 5 and 6 character Hids they should be padded to align correctly. + var shouldPad = page.Any(x => x.Hid.Length > 5); + // We may end up over the description character limit // so run it through a helper that "makes it work" :) eb.WithSimpleLineContent(page.Select(m => { - var ret = $"[`{m.DisplayHid(ctx.Config, isList: true)}`] **{m.NameFor(ctx)}** "; + var ret = $"[`{m.DisplayHid(ctx.Config, isList: true, shouldPad: shouldPad)}`] **{m.NameFor(ctx)}** "; if (opts.IncludeMessageCount && m.MessageCountFor(lookupCtx) is { } count) ret += $"({count} messages)"; @@ -237,11 +240,14 @@ public static class ContextListExt void ShortRenderer(EmbedBuilder eb, IEnumerable page) { + // if there are both 5 and 6 character Hids they should be padded to align correctly. + var shouldPad = page.Any(x => x.Hid.Length > 5); + // We may end up over the description character limit // so run it through a helper that "makes it work" :) eb.WithSimpleLineContent(page.Select(g => { - var ret = $"[`{g.DisplayHid(ctx.Config, isList: true)}`] **{g.NameFor(ctx)}** "; + var ret = $"[`{g.DisplayHid(ctx.Config, isList: true, shouldPad: shouldPad)}`] **{g.NameFor(ctx)}** "; switch (opts.SortProperty) { diff --git a/PluralKit.Bot/Utils/ModelUtils.cs b/PluralKit.Bot/Utils/ModelUtils.cs index 513f4e1d..ddeedfee 100644 --- a/PluralKit.Bot/Utils/ModelUtils.cs +++ b/PluralKit.Bot/Utils/ModelUtils.cs @@ -29,14 +29,14 @@ public static class ModelUtils 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) => + public static string DisplayHid(this PKGroup group, SystemConfig? cfg = null, bool isList = false, bool shouldPad = true) => HidTransform(group.Hid, cfg, isList, shouldPad); + public static string DisplayHid(this PKMember member, SystemConfig? cfg = null, bool isList = false, bool shouldPad = true) => HidTransform(member.Hid, cfg, isList, shouldPad); + private static string HidTransform(string hid, SystemConfig? cfg = null, bool isList = false, bool shouldPad = true) => HidUtils.HidTransform( hid, cfg != null && cfg.HidDisplaySplit, cfg != null && cfg.HidDisplayCaps, - isList ? (cfg?.HidListPadding ?? SystemConfig.HidPadFormat.None) : SystemConfig.HidPadFormat.None // padding only on lists + isList && shouldPad ? (cfg?.HidListPadding ?? SystemConfig.HidPadFormat.None) : SystemConfig.HidPadFormat.None // padding only on lists ); private static string EntityReference(string hid, string name)