mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Add InteractionMember#hasRole convince methods
This commit is contained in:
parent
e6af246170
commit
2a1957229f
@ -64,6 +64,20 @@ public interface InteractionMember {
|
||||
*/
|
||||
boolean hasRoles(List<String> roleDefinitions);
|
||||
|
||||
/**
|
||||
* Returns true if the user has the specified {@link InteractionRole role}.
|
||||
* @param role The role to check for.
|
||||
* @return true if the member has the specified role.
|
||||
*/
|
||||
boolean hasRole(InteractionRole role);
|
||||
|
||||
/**
|
||||
* Returns true if the user has a role by the specified ID.
|
||||
* @param roleId The role id to check for.
|
||||
* @return true if the member has a role by the specified ID.
|
||||
*/
|
||||
boolean hasRole(String roleId);
|
||||
|
||||
/**
|
||||
* Sends a private message to this member with the given content.
|
||||
* @param content The message to send.
|
||||
|
@ -3,7 +3,9 @@ package net.essentialsx.discord.interactions;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.PrivateChannel;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionMember;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionRole;
|
||||
import net.essentialsx.discord.util.DiscordUtil;
|
||||
|
||||
import java.util.List;
|
||||
@ -56,6 +58,21 @@ public class InteractionMemberImpl implements InteractionMember {
|
||||
return DiscordUtil.hasRoles(member, roleDefinitions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRole(InteractionRole role) {
|
||||
return hasRole(role.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRole(String roleId) {
|
||||
for (final Role role : member.getRoles()) {
|
||||
if (role.getId().equals(roleId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Member getJdaObject() {
|
||||
return member;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user