Fix console error when int parsing fails in clear message

This commit is contained in:
Bea 2022-12-19 00:13:14 +01:00
parent 2d1f6699ba
commit c9528848bc
1 changed files with 9 additions and 1 deletions

View File

@ -43,7 +43,15 @@ public class ClearCommand implements MessageCommand
// get the amount from the command args.
Integer toDeleteAmount;
if (args.length == 0) toDeleteAmount = 1;
else toDeleteAmount = Integer.parseInt(args[0]);
else
{
try {
toDeleteAmount = Integer.parseInt(args[0]);
} catch (NumberFormatException e)
{
toDeleteAmount = 1;
}
}
error = ClearChat.checkDeleteAmount(toDeleteAmount);
if (error != null) {