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

View File

@ -43,7 +43,15 @@ public class ClearCommand implements MessageCommand
// get the amount from the command args. // get the amount from the command args.
Integer toDeleteAmount; Integer toDeleteAmount;
if (args.length == 0) toDeleteAmount = 1; 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); error = ClearChat.checkDeleteAmount(toDeleteAmount);
if (error != null) { if (error != null) {