Implement various null checks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-01-15 04:51:30 +01:00
parent 546eb49144
commit d2abeb35fc
3 changed files with 28 additions and 6 deletions

View File

@@ -166,6 +166,7 @@ public class UserPunishment
Duration duration = null;
AuditableRestAction<Void> punishmentAction = null;
boolean impossible = false;
try {
switch (punishmentType) {
@@ -197,6 +198,14 @@ public class UserPunishment
}
}
} catch (RuntimeException ignored) {
impossible = true;
}
if(punishmentAction == null)
impossible = true;
if(impossible)
{
// todo nicer looking with emojis
return new MessageResponse("Sorry, I couldn't " + punishmentTypeName + " " + mentioned.getAsMention() + "!",
null);