Fixed bug with permissions
This commit is contained in:
parent
d4f6a52d44
commit
c6b613eae6
@ -170,20 +170,25 @@ public class MessageEvent {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onReact(MessageReactionAddEvent event) {
|
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 {
|
try {
|
||||||
m.invoke(reactRegistrar.getExecutor(), event);
|
Message message = event.getChannel().getMessageById(event.getMessageId()).complete();
|
||||||
} catch (Exception e) {
|
if (message == null || message.getEmbeds().size() != 1) return;
|
||||||
e.printStackTrace();
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user