forked from Fascinated/Bat
maybe fix npe??
This commit is contained in:
parent
3878d3029b
commit
bd9ac1e138
@ -49,11 +49,21 @@ public class BatGuild extends ProfileHolder {
|
|||||||
*/
|
*/
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The guild as the JDA Guild
|
||||||
|
*/
|
||||||
|
private Guild guild;
|
||||||
|
|
||||||
public BatGuild(@NonNull String id, @NonNull org.bson.Document document) {
|
public BatGuild(@NonNull String id, @NonNull org.bson.Document document) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.document = document;
|
this.document = document;
|
||||||
boolean newAccount = this.document.isEmpty();
|
boolean newAccount = this.document.isEmpty();
|
||||||
this.createdAt = newAccount ? new Date() : document.getDate("createdAt");
|
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
|
* @return the guild
|
||||||
*/
|
*/
|
||||||
public Guild getDiscordGuild() {
|
public Guild getDiscordGuild() {
|
||||||
return DiscordService.JDA.getGuildById(id);
|
if (guild == null) {
|
||||||
|
guild = DiscordService.JDA.getGuildById(id);
|
||||||
|
}
|
||||||
|
return guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user