Skip to content

Commit

Permalink
fix(validate): Misleading error message validating commands. (#2329)
Browse files Browse the repository at this point in the history
User and Message commands must have a description that is a empty
string. If the string was not empty it would print the following error:
  Error: command description must be between 1 and 100 characters

Resolves #2306.
  • Loading branch information
Erk- authored Apr 1, 2024
1 parent 703f016 commit 8f5cd0d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion twilight-validate/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ impl Display for CommandValidationError {

f.write_str(" characters")
}
CommandValidationErrorType::DescriptionNotAllowed => f.write_str(
"command description must be a empty string on message and user commands",
),
CommandValidationErrorType::NameLengthInvalid => {
f.write_str("command name must be between ")?;
Display::fmt(&NAME_LENGTH_MIN, f)?;
Expand Down Expand Up @@ -251,6 +254,8 @@ pub enum CommandValidationErrorType {
},
/// Command description is invalid.
DescriptionInvalid,
/// Command description must be a empty string.
DescriptionNotAllowed,
/// Command name length is invalid.
NameLengthInvalid,
/// Command name contain an invalid character.
Expand Down Expand Up @@ -327,7 +332,7 @@ pub fn command(value: &Command) -> Result<(), CommandValidationError> {
}
} else if !description.is_empty() {
return Err(CommandValidationError {
kind: CommandValidationErrorType::DescriptionInvalid,
kind: CommandValidationErrorType::DescriptionNotAllowed,
});
};

Expand Down

0 comments on commit 8f5cd0d

Please sign in to comment.