Skip to content

Commit

Permalink
feat(members): added utility methods for checking if a member has a s…
Browse files Browse the repository at this point in the history
…pecific role.
  • Loading branch information
seailz committed Sep 10, 2023
1 parent 57576bb commit dd6eb21
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/com/seailz/discordjar/model/guild/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,21 @@ public static Member decompile(@NotNull JSONObject obj, @NotNull DiscordJar disc
}

public Role[] roles() {
if (this.roleIds == null) {

}
if (this.roleIds == null) return null;
if (this.roles != null) return this.roles;
Role[] roles = discordJar.getGuildById(guildId).roles().stream().filter(role -> roleIds.contains(role.id())).toArray(Role[]::new);
this.roles = roles;
return roles;
}

public boolean hasRole(@NotNull String roleId) {
return roleIds.contains(roleId);
}

public boolean hasRole(@NotNull Role role) {
return roleIds.contains(role.id());
}

/**
* Nickname the member
* @param nick the nickname to set
Expand Down

0 comments on commit dd6eb21

Please sign in to comment.