Skip to content

Commit 693366e

Browse files
committed
make warn severity check more robust
1 parent 03fa9d5 commit 693366e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/net/javadiscord/javabot/util/InteractionUtils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,15 @@ public void handleModal(@Nonnull ModalInteractionEvent event, @Nonnull List<Moda
191191
return;
192192
}
193193
String reason = "None";
194-
WarnSeverity severity = id.length > 3 ? WarnSeverity.valueOf(id[3]) : null;
194+
WarnSeverity severity = WarnSeverity.MEDIUM;
195+
196+
if (id.length > 3) {
197+
try {
198+
severity = WarnSeverity.valueOf(id[3]);
199+
} catch (IllegalArgumentException e) {
200+
ExceptionLogger.capture(e, "Cannot load warn severity");
201+
}
202+
}
195203

196204
for (ModalMapping mapping : mappings) {
197205
if ("reason".equals(mapping.getId())) {

0 commit comments

Comments
 (0)