From 23139e3f626ecfea28330463e3c442fd4857dfc7 Mon Sep 17 00:00:00 2001 From: Ben Thomas Date: Sat, 18 Nov 2023 12:16:09 -0500 Subject: [PATCH] fix: Fixed an issue where an alias with a role that doesn't resolve would halt our discovery iterator for dropdowns --- .../gumcord/Interactions/InteractionHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java b/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java index 808069f..7fe5301 100644 --- a/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java +++ b/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java @@ -23,6 +23,7 @@ import java.awt.*; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; public class InteractionHandler extends ListenerAdapter { @@ -160,8 +161,14 @@ public static List> getMemberNewRoles(Guild guild, Member m var userRoleIDs = member.getRoles().stream().map(net.dv8tion.jda.api.entities.Role::getIdLong).collect(Collectors.toList()); // Now create a list of gumroad IDs that corresponds to the IDs the user already has + Map roles = gumGuild.getRoles(); aliases.forEach((alias, id) -> { - if (!userRoleIDs.contains(gumGuild.getRoles().get(id).RoleId)) { + if (!roles.containsKey(id)) { + return; + } + + GumRole foundRole = roles.get(id); + if (!userRoleIDs.contains(foundRole.RoleId)) { returnList.add(new Pair<>(alias, id)); } });