diff --git a/PluralKit.Bot/Commands/Lists/ContextListExt.cs b/PluralKit.Bot/Commands/Lists/ContextListExt.cs index ef820155..d0891787 100644 --- a/PluralKit.Bot/Commands/Lists/ContextListExt.cs +++ b/PluralKit.Bot/Commands/Lists/ContextListExt.cs @@ -76,11 +76,18 @@ public static class ContextListExt if (ctx.MatchFlag("with-displayname", "wdn")) p.IncludeDisplayName = true; - // Always show the sort property, too - if (p.SortProperty == SortProperty.LastSwitch) p.IncludeLastSwitch = true; - if (p.SortProperty == SortProperty.LastMessage) p.IncludeLastMessage = true; - if (p.SortProperty == SortProperty.MessageCount) p.IncludeMessageCount = true; - if (p.SortProperty == SortProperty.CreationDate) p.IncludeCreated = true; + // Always show the sort property, too (unless this is the short list) + if (p.Type != ListType.Short) + { + if (p.SortProperty == SortProperty.DisplayName) p.IncludeDisplayName = true; + if (p.SortProperty == SortProperty.MessageCount) p.IncludeMessageCount = true; + if (p.SortProperty == SortProperty.CreationDate) p.IncludeCreated = true; + if (p.SortProperty == SortProperty.LastSwitch) p.IncludeLastSwitch = true; + if (p.SortProperty == SortProperty.LastMessage) p.IncludeLastMessage = true; + } + + // Make sure the options are valid + p.AssertIsValid(); // Done! return p; diff --git a/PluralKit.Bot/Commands/Lists/ListOptions.cs b/PluralKit.Bot/Commands/Lists/ListOptions.cs index 39e12367..7d9b4471 100644 --- a/PluralKit.Bot/Commands/Lists/ListOptions.cs +++ b/PluralKit.Bot/Commands/Lists/ListOptions.cs @@ -11,7 +11,20 @@ namespace PluralKit.Bot; public class ListOptions { - public SortProperty SortProperty { get; set; } = SortProperty.Name; + private SortProperty? _sortProperty { get; set; } + public SortProperty SortProperty + { + get => _sortProperty ?? SortProperty.Name; + set + { + if (_sortProperty != null) + throw new PKError("Cannot sort in multiple ways at the same time. Please choose only one sorting method."); + + _sortProperty = value; + } + } + + public bool Reverse { get; set; } public PrivacyLevel? PrivacyFilter { get; set; } = PrivacyLevel.Public; @@ -148,6 +161,27 @@ public static class ListOptionsExt // Lastly, add a by-name fallback order for collisions (generally hits w/ lots of null values) .ThenBy(g => g.NameFor(ctx), culture); } + + public static void AssertIsValid(this ListOptions opts) + { + if (opts.Type == ListType.Short) + { + var hasMultipleIncluded = new[] { + opts.IncludeMessageCount, + opts.IncludeLastSwitch, + opts.IncludeLastMessage, + opts.IncludeCreated, + opts.IncludeAvatar, + opts.IncludePronouns, + opts.IncludeDisplayName, + }.Sum(x => Convert.ToInt32(x)) > 0; + + if (hasMultipleIncluded) + throw new PKError("The short list does not support showing items from multiple flags. Try using the full list instead."); + } + + // the check for multiple *sorting* property flags is done in SortProperty setter + } } public enum SortProperty