Skip to content

Commit e96da4a

Browse files
authored
Add Null Safety to member in CmdApplication
1 parent 6744315 commit e96da4a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/io/codemc/bot/commands/CmdApplication.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static void handle(CodeMCBot bot, InteractionHook hook, Guild guild, long
9393
return;
9494
}
9595

96-
String userId = embed.getFooter().getText();
96+
String userId = embed.getFooter().getText().trim();
9797
if(userId == null || userId.isEmpty()){
9898
CommandUtil.EmbedReply.from(hook).error("Embed does not have a valid footer.").send();
9999
return;
@@ -151,8 +151,12 @@ public static void handle(CodeMCBot bot, InteractionHook hook, Guild guild, long
151151
boolean nexusSuccess = APIUtil.createNexus(hook, username, password);
152152
if (!nexusSuccess || !jenkinsSuccess) return;
153153

154-
if (DatabaseAPI.getUser(username) == null)
155-
DatabaseAPI.addUser(username, member.getIdLong());
154+
if (member == null)
155+
LOGGER.warn("Member with ID '{}' not found!", userId);
156+
else {
157+
if (DatabaseAPI.getUser(username) == null)
158+
DatabaseAPI.addUser(username, member.getIdLong());
159+
}
156160
}
157161

158162
channel.sendMessage(getMessage(bot, userId, userLink, repoLink, str == null ? jenkinsUrl : str, hook.getInteraction().getUser(), accepted)).queue(m -> {

0 commit comments

Comments
 (0)