mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-15 02:00:09 +00:00
fix(commands): add separate missing error for Token::Any to relay a better error message to user
This commit is contained in:
parent
8a01d7d37a
commit
58b5a26eca
3 changed files with 20 additions and 3 deletions
|
|
@ -101,6 +101,21 @@ pub fn parse_command(prefix: String, input: String) -> CommandResult {
|
|||
TokenMatchError::MissingParameter { name } => {
|
||||
format!("Expected parameter `{name}` in command `{prefix}{input} {token}`.")
|
||||
}
|
||||
TokenMatchError::MissingAny { tokens } => {
|
||||
let mut msg = format!("Expected one of ");
|
||||
for (idx, token) in tokens.iter().enumerate() {
|
||||
write!(&mut msg, "`{token}`").expect("oom");
|
||||
if idx < tokens.len() - 1 {
|
||||
if tokens.len() > 2 && idx == tokens.len() - 2 {
|
||||
msg.push_str(" or ");
|
||||
} else {
|
||||
msg.push_str(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
write!(&mut msg, " in command `{prefix}{input} {token}`.").expect("oom");
|
||||
msg
|
||||
}
|
||||
};
|
||||
return CommandResult::Err { error: error_msg };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue