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