Bat/src/main/java/cc/fascinated/bat/common/RoleUtils.java
Liam 055c8709f8
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 45s
add check to see if the bot can give the role when adding a new role to the auto role list
2024-06-25 16:45:59 +01:00

23 lines
706 B
Java

package cc.fascinated.bat.common;
import cc.fascinated.bat.model.BatGuild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
/**
* @author Fascinated (fascinated7)
*/
public class RoleUtils {
/**
* Checks if a member has permission to give the role to another member
*
* @param guild the guild to check
* @param member the member to check
* @param role the role to check
* @return if the member has permission to give the role
*/
public static boolean hasPermissionToGiveRole(BatGuild guild, Member member, Role role) {
return member.getRoles().stream().anyMatch(r -> r.getPosition() > role.getPosition());
}
}