mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-07 14:27:54 +00:00
fix(commands): prefix in missing parameter error
This commit is contained in:
parent
4cf17263d1
commit
319a79d1d6
1 changed files with 6 additions and 3 deletions
|
|
@ -69,7 +69,7 @@ pub fn parse_command(prefix: String, input: String) -> CommandResult {
|
|||
loop {
|
||||
let possible_tokens = local_tree.possible_tokens().cloned().collect::<Vec<_>>();
|
||||
println!("possible: {:?}", possible_tokens);
|
||||
let next = next_token(possible_tokens.clone(), input.clone(), current_pos);
|
||||
let next = next_token(possible_tokens.clone(), &prefix, input.clone(), current_pos);
|
||||
println!("next: {:?}", next);
|
||||
match next {
|
||||
Ok((found_token, arg, new_pos)) => {
|
||||
|
|
@ -113,7 +113,9 @@ pub fn parse_command(prefix: String, input: String) -> CommandResult {
|
|||
if !possible_commands.is_empty() {
|
||||
error.push_str(" Perhaps you meant to use one of the commands below:\n");
|
||||
for command in possible_commands.iter().take(MAX_SUGGESTIONS) {
|
||||
if !command.show_in_suggestions { continue }
|
||||
if !command.show_in_suggestions {
|
||||
continue;
|
||||
}
|
||||
writeln!(&mut error, "- **{prefix}{command}** - *{}*", command.help)
|
||||
.expect("oom");
|
||||
}
|
||||
|
|
@ -147,6 +149,7 @@ pub fn parse_command(prefix: String, input: String) -> CommandResult {
|
|||
/// - optionally a short-circuit error
|
||||
fn next_token(
|
||||
possible_tokens: Vec<Token>,
|
||||
prefix: &str,
|
||||
input: SmolStr,
|
||||
current_pos: usize,
|
||||
) -> Result<(Token, Option<TokenMatchedValue>, usize), Option<SmolStr>> {
|
||||
|
|
@ -180,7 +183,7 @@ fn next_token(
|
|||
}
|
||||
TokenMatchResult::MissingParameter { name } => {
|
||||
return Err(Some(format_smolstr!(
|
||||
"Missing parameter `{name}` in command `{input} [{name}]`."
|
||||
"Missing parameter `{name}` in command `{prefix}{input} [{name}]`."
|
||||
)))
|
||||
}
|
||||
TokenMatchResult::NoMatch => {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue