mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-05-08 02:10:05 -05:00
This should also fix some more errors with getting users/roles
This commit is contained in:
@@ -21,6 +21,14 @@ public class RoleUtils {
|
||||
.next();
|
||||
}
|
||||
|
||||
public static Mono<Role> getRoleFromID(String id, Guild guild) {
|
||||
return Mono.just(id)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.filter(s -> s.matches("[0-9]+"))
|
||||
.flatMap(s -> guild.getRoleById(Snowflake.of(id))
|
||||
.onErrorResume(e -> Mono.empty()));
|
||||
}
|
||||
|
||||
public static Mono<Boolean> roleExists(String id, MessageCreateEvent event) {
|
||||
return getRoleFromID(id, event).hasElement();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ public class UserUtils {
|
||||
}
|
||||
|
||||
public static Mono<Member> getUser(String toLookFor, Guild guild) {
|
||||
if (toLookFor.isEmpty())
|
||||
return Mono.empty();
|
||||
|
||||
toLookFor = GeneralUtils.trim(toLookFor);
|
||||
final String lower = toLookFor.toLowerCase();
|
||||
if (lower.matches("@!?[0-9]+") || lower.matches("[0-9]+")) {
|
||||
@@ -47,9 +50,12 @@ public class UserUtils {
|
||||
.onErrorResume(e -> Mono.empty()); //User not found, we don't care about the error in this case.
|
||||
}
|
||||
|
||||
private static Mono<Member> getUserFromID(String id, Guild guild) {
|
||||
return guild.getMemberById(Snowflake.of(id))
|
||||
.onErrorResume(e -> Mono.empty());
|
||||
public static Mono<Member> getUserFromID(String id, Guild guild) {
|
||||
return Mono.just(id)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.filter(s -> s.matches("[0-9]+"))
|
||||
.flatMap(s -> guild.getMemberById(Snowflake.of(s))
|
||||
.onErrorResume(e -> Mono.empty()));
|
||||
}
|
||||
|
||||
public static Mono<List<Member>> getUsers(ArrayList<String> userIds, Guild guild) {
|
||||
|
||||
Reference in New Issue
Block a user