diff --git a/src/main/java/cc/fascinated/bat/model/BatGuild.java b/src/main/java/cc/fascinated/bat/model/BatGuild.java index fb40213..8b886a5 100644 --- a/src/main/java/cc/fascinated/bat/model/BatGuild.java +++ b/src/main/java/cc/fascinated/bat/model/BatGuild.java @@ -49,11 +49,21 @@ public class BatGuild extends ProfileHolder { */ private Date createdAt; + /** + * The guild as the JDA Guild + */ + private Guild guild; + public BatGuild(@NonNull String id, @NonNull org.bson.Document document) { this.id = id; this.document = document; boolean newAccount = this.document.isEmpty(); this.createdAt = newAccount ? new Date() : document.getDate("createdAt"); + + Guild guild = DiscordService.JDA.getGuildById(id); + if (guild != null) { + this.guild = guild; + } } /** @@ -71,7 +81,10 @@ public class BatGuild extends ProfileHolder { * @return the guild */ public Guild getDiscordGuild() { - return DiscordService.JDA.getGuildById(id); + if (guild == null) { + guild = DiscordService.JDA.getGuildById(id); + } + return guild; } /**