diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index 2c11d02f..3ecdc070 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -10,14 +10,16 @@ public partial class CommandTree { case "fun_thunder": return ctx.Execute(null, m => m.Thunder(ctx)); - default: - // don't send an "invalid command" response if the guild has those turned off - if (ctx.GuildConfig != null && ctx.GuildConfig!.InvalidCommandResponseEnabled != true) - return Task.CompletedTask; - - // remove compiler warning + case "help": + return ctx.Execute(Help, m => m.HelpRoot(ctx)); + case "help_commands": + return ctx.Reply("For the list of commands, see the website: "); + case "help_proxy": return ctx.Reply( - $"{Emojis.Error} Unknown command {ctx.PeekArgument().AsCode()}. For a list of possible commands, see ."); + "The proxy help page has been moved! See the website: https://pluralkit.me/guide#proxying"); + default: + // remove compiler warning + return ctx.Reply($"{Emojis.Error} Parsed command {ctx.Parameters.Callback().AsCode()} not implemented in PluralKit.Bot!"); } if (ctx.Match("system", "s")) return HandleSystemCommand(ctx); @@ -50,13 +52,6 @@ public partial class CommandTree return ctx.Execute(Import, m => m.Import(ctx)); if (ctx.Match("export")) return ctx.Execute(Export, m => m.Export(ctx)); - if (ctx.Match("help", "h")) - if (ctx.Match("commands")) - return ctx.Reply("For the list of commands, see the website: "); - else if (ctx.Match("proxy")) - return ctx.Reply( - "The proxy help page has been moved! See the website: https://pluralkit.me/guide#proxying"); - else return ctx.Execute(Help, m => m.HelpRoot(ctx)); if (ctx.Match("explain")) return ctx.Execute(Explain, m => m.Explain(ctx)); if (ctx.Match("message", "msg", "messageinfo")) diff --git a/PluralKit.Bot/CommandSystem/Context/Context.cs b/PluralKit.Bot/CommandSystem/Context/Context.cs index c212e2e5..244725f8 100644 --- a/PluralKit.Bot/CommandSystem/Context/Context.cs +++ b/PluralKit.Bot/CommandSystem/Context/Context.cs @@ -57,8 +57,12 @@ public class Context } catch (PKError e) { - // todo: not this - Reply($"{Emojis.Error} {e.Message}"); + // don't send an "invalid command" response if the guild has those turned off + if (!(GuildConfig != null && GuildConfig!.InvalidCommandResponseEnabled != true)) + { + // todo: not this + Reply($"{Emojis.Error} {e.Message}"); + } throw; } } diff --git a/crates/commands/src/commands/fun.rs b/crates/commands/src/commands/fun.rs index a3ba0d9e..472997ac 100644 --- a/crates/commands/src/commands/fun.rs +++ b/crates/commands/src/commands/fun.rs @@ -4,7 +4,7 @@ pub fn cmds() -> impl Iterator { [command!( ["thunder"], "fun_thunder", - "Shows the help command" + "fun thunder" )] .into_iter() } diff --git a/crates/commands/src/commands/help.rs b/crates/commands/src/commands/help.rs index 269d87a9..86ec0f97 100644 --- a/crates/commands/src/commands/help.rs +++ b/crates/commands/src/commands/help.rs @@ -11,7 +11,12 @@ pub fn cmds() -> impl Iterator { command!( [help, "commands"], "help_commands", - "Commands" + "help commands" + ), + command!( + [help, "proxy"], + "help_proxy", + "help proxy" ), ] .into_iter() diff --git a/crates/commands/src/commands/system.rs b/crates/commands/src/commands/system.rs index bbc449ed..3e10e992 100644 --- a/crates/commands/src/commands/system.rs +++ b/crates/commands/src/commands/system.rs @@ -14,7 +14,7 @@ pub fn cmds() -> impl Iterator { ), command!([system, new], "system_new", "Creates a new system"), command!( - [system, new, FullString], + [system, new, SystemRef], "system_new", "Creates a new system" ), diff --git a/crates/commands/src/lib.rs b/crates/commands/src/lib.rs index f2b4a969..4b239cd1 100644 --- a/crates/commands/src/lib.rs +++ b/crates/commands/src/lib.rs @@ -93,7 +93,7 @@ fn parse_command(input: String) -> CommandResult { // todo: check if last token is a common incorrect unquote (multi-member names etc) // todo: check if this is a system name in pk;s command return CommandResult::Err { - error: "Command not found.".to_string(), + error: format!("Unknown command `{input}`. For a list of possible commands, see ."), }; } Err(Some(short_circuit)) => { diff --git a/crates/commands/src/token.rs b/crates/commands/src/token.rs index 3b59fe38..3d933668 100644 --- a/crates/commands/src/token.rs +++ b/crates/commands/src/token.rs @@ -18,6 +18,9 @@ pub enum Token { MemberRef, MemberPrivacyTarget, + /// System reference + SystemRef, + PrivacyLevel, // currently not included in command definitions @@ -32,13 +35,7 @@ pub enum TokenMatchResult { } // move this somewhere else -lazy_static::lazy_static!( - static ref MEMBER_PRIVACY_TARGETS: Vec = [ - "visibility", - "name", - "todo", - ].into_iter().map(SmolStr::new_static).collect(); -); +const MEMBER_PRIVACY_TARGETS: &[&str] = &["visibility", "name", "todo"]; impl Token { pub fn try_match(&self, input: Option) -> TokenMatchResult { @@ -66,12 +63,9 @@ impl Token { } Self::MultiValue(_) => todo!(), Self::FullString => return TokenMatchResult::Match(Some(input)), + Self::SystemRef => return TokenMatchResult::Match(Some(input)), Self::MemberRef => return TokenMatchResult::Match(Some(input)), - Self::MemberPrivacyTarget - if MEMBER_PRIVACY_TARGETS - .iter() - .any(|target| target.eq(input.trim())) => - { + Self::MemberPrivacyTarget if MEMBER_PRIVACY_TARGETS.contains(&input.trim()) => { return TokenMatchResult::Match(Some(input)) } Self::MemberPrivacyTarget => {} @@ -107,4 +101,4 @@ impl ToToken for [&str] { fn to_token(&self) -> Token { Token::Value(self.into_iter().map(|s| s.to_smolstr()).collect()) } -} \ No newline at end of file +}