From dd6eb21a8ff6f3f76231a5e34a5301802671566d Mon Sep 17 00:00:00 2001 From: IoyoCode Date: Sun, 10 Sep 2023 19:27:12 +0100 Subject: [PATCH] feat(members): added utility methods for checking if a member has a specific role. --- .../com/seailz/discordjar/model/guild/Member.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/seailz/discordjar/model/guild/Member.java b/src/main/java/com/seailz/discordjar/model/guild/Member.java index b0d95b1e..b36c2f4e 100644 --- a/src/main/java/com/seailz/discordjar/model/guild/Member.java +++ b/src/main/java/com/seailz/discordjar/model/guild/Member.java @@ -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