From c6b613eae63df1c3bfb219d9d4518e0e8199e2c3 Mon Sep 17 00:00:00 2001 From: Savvy Date: Mon, 2 Oct 2017 22:37:06 -0400 Subject: [PATCH] Fixed bug with permissions --- .../me/savvy/rixa/events/MessageEvent.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/savvy/rixa/events/MessageEvent.java b/src/main/java/me/savvy/rixa/events/MessageEvent.java index 156e190..3eb7dc2 100644 --- a/src/main/java/me/savvy/rixa/events/MessageEvent.java +++ b/src/main/java/me/savvy/rixa/events/MessageEvent.java @@ -170,20 +170,25 @@ public class MessageEvent { @SubscribeEvent public void onReact(MessageReactionAddEvent event) { - Message message = event.getChannel().getMessageById(event.getMessageId()).complete(); - if (message == null || message.getEmbeds().size() != 1) return; - MessageEmbed embed = message.getEmbeds().get(0); - if (StringUtils.isNullOrEmpty(embed.getTitle())) return; - String[] titleSplit = embed.getTitle().split(": "); - if (titleSplit[0].equalsIgnoreCase("Leaderboard")) return; - if (!ReactionManager.getReactions().containsKey(titleSplit[0])) return; - - ReactRegistrar reactRegistrar = ReactionManager.getReactions().get(titleSplit[0]); - Method m = reactRegistrar.getMethod(); try { - m.invoke(reactRegistrar.getExecutor(), event); - } catch (Exception e) { - e.printStackTrace(); + Message message = event.getChannel().getMessageById(event.getMessageId()).complete(); + if (message == null || message.getEmbeds().size() != 1) return; + MessageEmbed embed = message.getEmbeds().get(0); + if (StringUtils.isNullOrEmpty(embed.getTitle())) return; + String[] titleSplit = embed.getTitle().split(": "); + if (titleSplit[0].equalsIgnoreCase("Leaderboard")) return; + if (!ReactionManager.getReactions().containsKey(titleSplit[0])) return; + + ReactRegistrar reactRegistrar = ReactionManager.getReactions().get(titleSplit[0]); + Method m = reactRegistrar.getMethod(); + try { + m.invoke(reactRegistrar.getExecutor(), event); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (PermissionException pex) { + if (pex.getPermission() == Permission.MESSAGE_READ) return; + pex.printStackTrace(); } }