use of me.piggypiglet.gary.core.objects.paginations.PaginationPage in project Gary by help-chat.
the class PaginationHandler method execute.
@Override
protected void execute(GenericEvent event) {
switch(EventsEnum.fromEvent(event)) {
case MESSAGE_REACTION_ADD:
GuildMessageReactionAddEvent e = (GuildMessageReactionAddEvent) event;
if (!e.getMember().getUser().isBot()) {
String messageId = e.getMessageId();
if (paginations.containsKey(messageId)) {
MessageReaction.ReactionEmote reactionEmote = e.getReactionEmote();
PaginationPage newPage;
if (reactionEmote.getEmote() == null) {
newPage = paginations.get(messageId).getPage(reactionEmote.getName());
} else {
newPage = paginations.get(messageId).getPage(reactionEmote.getEmote());
}
if (newPage != null) {
Object newMessage = newPage.getMessage();
Message message = e.getChannel().retrieveMessageById(messageId).complete();
if (newMessage instanceof String) {
message.editMessage((String) newMessage).queue();
} else if (newMessage instanceof MessageEmbed) {
message.editMessage((MessageEmbed) newMessage).override(true).queue();
}
e.getReaction().removeReaction(e.getUser()).queue();
}
}
}
break;
case MESSAGE_DELETE:
paginations.remove(((GuildMessageDeleteEvent) event).getMessageId());
break;
}
}
Aggregations