From 35596b720b61f1e38505afeea7d80f4e083b4ac5 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 3 Jul 2024 00:14:00 +0100 Subject: [PATCH] maybe fix a NPE?? --- src/main/java/cc/fascinated/bat/model/BatUser.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/fascinated/bat/model/BatUser.java b/src/main/java/cc/fascinated/bat/model/BatUser.java index 7acf7c4..9ae3118 100644 --- a/src/main/java/cc/fascinated/bat/model/BatUser.java +++ b/src/main/java/cc/fascinated/bat/model/BatUser.java @@ -53,6 +53,11 @@ public class BatUser extends ProfileHolder { */ private Date createdAt; + /** + * The discord user associated with this user + */ + private User user; + public BatUser(@NonNull String id, @NonNull org.bson.Document document) { this.id = id; this.document = document; @@ -61,6 +66,7 @@ public class BatUser extends ProfileHolder { User user = DiscordService.JDA.getUserById(id); if (user != null) { + this.user = user; this.globalName = user.getGlobalName(); } } @@ -78,7 +84,10 @@ public class BatUser extends ProfileHolder { * @return the guild */ public User getDiscordUser() { - return DiscordService.JDA.getUserById(id); + if (user == null) { + user = DiscordService.JDA.getUserById(id); + } + return user; } /**