Skip to content

Commit 7de016c

Browse files
authored
fix: invalid timestamp parsing (#57)
Fix an error where the bot would create a reminder for current time + 0 when an invalid timestamp was provided, and return a descriptive error message instead.
1 parent 8f845d9 commit 7de016c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Bot/Systems/Commands/Text/Parsers/TimeSpanParser.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static TypeParserResult<TimeSpan> Parse(string value)
3333
if (match.Groups["Seconds"].Success && match.Groups["Seconds"].Value[r].TryParse<int>(out var seconds))
3434
result += seconds.Seconds();
3535

36+
if (match.Groups["0"].Success && result == TimeSpan.Zero)
37+
return Failure($"\"{value}\" could not be interpreted as a valid time span.");
38+
3639
return Success(result);
3740
}
3841

0 commit comments

Comments
 (0)