diff --git a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs index 63e4f92f..90c3bb39 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs @@ -90,17 +90,23 @@ public static class ContextArgumentsExt public static async Task MatchClear(this Context ctx, string toClear = null) { - var matched = ctx.Match("clear", "reset") || ctx.MatchFlag("c", "clear"); + var matched = ctx.MatchClearInner(); if (matched && toClear != null) return await ctx.ConfirmClear(toClear); return matched; } + private static bool MatchClearInner(this Context ctx) + => ctx.Match("clear", "reset", "default") || ctx.MatchFlag("c", "clear"); + public static bool MatchRaw(this Context ctx) => ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw"); - public static bool MatchToggle(this Context ctx) + public static bool MatchToggle(this Context ctx, bool? defaultValue = null) { + if (defaultValue != null && ctx.MatchClearInner()) + return defaultValue.Value; + var yesToggles = new[] { "yes", "on", "enable", "enabled", "true" }; var noToggles = new[] { "no", "off", "disable", "disabled", "false" }; diff --git a/PluralKit.Bot/Commands/Config.cs b/PluralKit.Bot/Commands/Config.cs index 50637dad..5831abf5 100644 --- a/PluralKit.Bot/Commands/Config.cs +++ b/PluralKit.Bot/Commands/Config.cs @@ -111,6 +111,9 @@ public class Config eb.Description(description.ToString()); + // using *large* blue diamond here since it's easier to see in the small footer + eb.Footer(new("\U0001f537 means this setting was changed. Type `pk;config clear` to reset it to the default.")); + return Task.CompletedTask; } ); @@ -125,7 +128,7 @@ public class Config return; } - var allow = ctx.MatchToggle(); + var allow = ctx.MatchToggle(true); var statusString = EnabledDisabled(allow); if (ctx.MessageContext.AllowAutoproxy == allow) @@ -159,7 +162,7 @@ public class Config Duration? newTimeout; Duration overflow = Duration.Zero; if (ctx.Match("off", "stop", "cancel", "no", "disable", "remove")) newTimeout = Duration.Zero; - else if (ctx.Match("reset", "default")) newTimeout = null; + else if (await ctx.MatchClear()) newTimeout = null; else { var timeoutStr = ctx.RemainderOrNull(); @@ -295,7 +298,7 @@ public class Config return; } - var value = ctx.MatchToggle(); + var value = ctx.MatchToggle(true); if (ctx.Config.PingsEnabled == value) await ctx.Reply(Response(true, ctx.Config.PingsEnabled)); @@ -315,7 +318,7 @@ public class Config } else { - if (ctx.MatchToggle()) + if (ctx.MatchToggle(false)) { await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { MemberDefaultPrivate = true }); @@ -339,7 +342,7 @@ public class Config } else { - if (ctx.MatchToggle()) + if (ctx.MatchToggle(false)) { await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { GroupDefaultPrivate = true }); @@ -363,7 +366,7 @@ public class Config return; } - if (ctx.MatchToggle()) + if (ctx.MatchToggle(true)) { await ctx.Repository.UpdateSystemConfig(ctx.System.Id, new() { ShowPrivateInfo = true });