a lil cleanup and add role perms when adding and removing a role to the log
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 59s

This commit is contained in:
Lee
2024-07-04 18:04:15 +01:00
parent 313f43172d
commit 75da7a4b51
2 changed files with 22 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package cc.fascinated.bat.common;
import cc.fascinated.bat.model.BatGuild;
import lombok.experimental.UtilityClass;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
@ -21,4 +22,18 @@ public class RoleUtils {
public static boolean hasPermissionToGiveRole(BatGuild guild, Member member, Role role) {
return member.getRoles().stream().anyMatch(r -> r.getPosition() > role.getPosition());
}
/**
* Gets the formatted permissions of a role
*
* @param role the role to get the formatted permissions of
* @return the formatted permissions
*/
public String getFormattedPermissions(Role role) {
StringBuilder formattedPermissions = new StringBuilder();
for (Permission permission : role.getPermissions()) {
formattedPermissions.append("`").append(permission.getName()).append("`, ");
}
return formattedPermissions.substring(0, formattedPermissions.length() - 2);
}
}