From c62b9c2d4064672c0d9b1654b5fbf72942d47041 Mon Sep 17 00:00:00 2001 From: rladenson <78043712+rladenson@users.noreply.github.com> Date: Wed, 19 Jan 2022 17:21:37 -0500 Subject: [PATCH] feat: add -with-displayname flag to lists --- PluralKit.Bot/Commands/Lists/ContextListExt.cs | 10 ++++++++++ PluralKit.Bot/Commands/Lists/ListOptions.cs | 1 + docs/content/tips-and-tricks.md | 1 + 3 files changed, 12 insertions(+) diff --git a/PluralKit.Bot/Commands/Lists/ContextListExt.cs b/PluralKit.Bot/Commands/Lists/ContextListExt.cs index a7ad6c78..29af66dd 100644 --- a/PluralKit.Bot/Commands/Lists/ContextListExt.cs +++ b/PluralKit.Bot/Commands/Lists/ContextListExt.cs @@ -75,6 +75,8 @@ public static class ContextListExt p.IncludeAvatar = true; if (ctx.MatchFlag("with-pronouns", "wp")) p.IncludePronouns = true; + if (ctx.MatchFlag("with-displayname", "wdn")) + p.IncludeDisplayName = true; // Always show the sort property, too if (p.SortProperty == SortProperty.LastSwitch) p.IncludeLastSwitch = true; @@ -166,6 +168,10 @@ public static class ContextListExt { ret += $"({count} messages)"; } + else if (opts.IncludeDisplayName && m.DisplayName != null && m.NamePrivacy.CanAccess(lookupCtx)) + { + ret += $"({m.DisplayName})"; + } else if (opts.IncludeLastSwitch && m.MetadataPrivacy.TryGet(lookupCtx, m.LastSwitchTime, out var lastSw)) { @@ -305,6 +311,10 @@ public static class ContextListExt { ret += $"(created at )"; } + else if (opts.IncludeDisplayName && g.DisplayName != null && g.NamePrivacy.CanAccess(lookupCtx)) + { + ret += $"({g.DisplayName})"; + } else if (opts.IncludeAvatar && g.IconFor(lookupCtx) is { } avatarUrl) { ret += $"([avatar URL]({avatarUrl}))"; diff --git a/PluralKit.Bot/Commands/Lists/ListOptions.cs b/PluralKit.Bot/Commands/Lists/ListOptions.cs index 051344a0..c42ccc1e 100644 --- a/PluralKit.Bot/Commands/Lists/ListOptions.cs +++ b/PluralKit.Bot/Commands/Lists/ListOptions.cs @@ -24,6 +24,7 @@ public class ListOptions public bool IncludeCreated { get; set; } public bool IncludeAvatar { get; set; } public bool IncludePronouns { get; set; } + public bool IncludeDisplayName { get; set; } public string CreateFilterString() { diff --git a/docs/content/tips-and-tricks.md b/docs/content/tips-and-tricks.md index e2266097..e697fc79 100644 --- a/docs/content/tips-and-tricks.md +++ b/docs/content/tips-and-tricks.md @@ -64,6 +64,7 @@ You cannot look up private members or groups of another system. |-with-created|-wc|Member, Group|Show each item's creation date| |-with-avatar|-wa, -wi, -ia, -ii, -img|Member, Group|Show each item's avatar URL| |-with-pronouns|-wp|Member|Show each member's pronouns in the short list (shown by default in full list)| +|-with-displayname|-wdn|Member, Group|Show each item's displayname| ## Miscellaneous flags |Command|Flag|Aliases|Description|