Fix roles failing to load from name
This commit is contained in:
@@ -6,6 +6,7 @@ package com.hypherionmc.sdlink.core.managers;
|
||||
|
||||
import com.hypherionmc.sdlink.core.config.SDLinkConfig;
|
||||
import com.hypherionmc.sdlink.core.discord.BotController;
|
||||
import com.hypherionmc.sdlink.core.util.SystemUtils;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -63,7 +64,10 @@ public class RoleManager {
|
||||
* @return The role that matched or NULL
|
||||
*/
|
||||
private static Role getRole(AtomicInteger errCount, StringBuilder builder, String roleIdentifier, String roleID) {
|
||||
Role role = BotController.INSTANCE.getJDA().getRoleById(roleID);
|
||||
Role role = null;
|
||||
if (SystemUtils.isLong(roleID)) {
|
||||
role = BotController.INSTANCE.getJDA().getRoleById(roleID);
|
||||
}
|
||||
|
||||
if (role != null) {
|
||||
return role;
|
||||
|
@@ -92,10 +92,11 @@ public class SystemUtils {
|
||||
return new Random().ints(1000, 9999).findFirst().getAsInt();
|
||||
}
|
||||
|
||||
/*public static boolean hasPermission(BotController controller, Member member) {
|
||||
if (controller.getAdminRole() != null) {
|
||||
return member.getRoles().stream().anyMatch(r -> r.getIdLong() == controller.getAdminRole().getIdLong());
|
||||
}
|
||||
return member.hasPermission(Permission.ADMINISTRATOR) || member.hasPermission(Permission.KICK_MEMBERS);
|
||||
}*/
|
||||
public static boolean isLong(String input) {
|
||||
try {
|
||||
Long.parseLong(input);
|
||||
return true;
|
||||
} catch (NumberFormatException ignored){}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user