Search in sources :

Example 1 with ReactionEmote

use of net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote in project Bean by Xirado.

the class MessageReactionAddListener method onMessageReactionAdd.

@Override
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent e) {
    if (!e.isFromGuild())
        return;
    if (GuildJoinListener.isGuildBanned(e.getGuild().getIdLong()))
        return;
    try {
        if (e.getMember().getUser().isBot())
            return;
        Guild g = e.getGuild();
        long id = e.getMessageIdLong();
        ReactionEmote reactionemote = e.getReactionEmote();
        String reacted = reactionemote.isEmoji() ? reactionemote.getAsReactionCode() : reactionemote.getEmote().getId();
        GuildData data = GuildManager.getGuildData(e.getGuild());
        ReactionRole reactionRole = data.getReactionRoles().stream().filter(x -> x.getMessageId() == id && x.getEmote().equals(reacted)).findFirst().orElse(null);
        if (reactionRole != null) {
            Role role = e.getGuild().getRoleById(reactionRole.getRoleId());
            if (role != null)
                g.addRoleToMember(e.getMember(), role).queue(s -> {
                }, ex -> {
                });
        }
    } catch (Exception e2) {
        LOGGER.error("An error occured whilst executing reaction role event!", e2);
    }
}
Also used : Role(net.dv8tion.jda.api.entities.Role) ReactionRole(at.xirado.bean.data.ReactionRole) GuildManager(at.xirado.bean.data.GuildManager) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) GuildData(at.xirado.bean.data.GuildData) Guild(net.dv8tion.jda.api.entities.Guild) Logger(org.slf4j.Logger) Role(net.dv8tion.jda.api.entities.Role) ReactionRole(at.xirado.bean.data.ReactionRole) LoggerFactory(org.slf4j.LoggerFactory) ListenerAdapter(net.dv8tion.jda.api.hooks.ListenerAdapter) MessageReactionAddEvent(net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent) NotNull(org.jetbrains.annotations.NotNull) GuildData(at.xirado.bean.data.GuildData) Guild(net.dv8tion.jda.api.entities.Guild) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) ReactionRole(at.xirado.bean.data.ReactionRole)

Example 2 with ReactionEmote

use of net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote in project Minecord by Tisawesomeness.

the class ReactListener method onMessageReactionAdd.

@Override
public void onMessageReactionAdd(MessageReactionAddEvent e) {
    // Make sure message matches
    HashMap<Long, ReactMenu> menus = ReactMenu.getMenus();
    if (menus.containsKey(e.getMessageIdLong())) {
        // Make sure owner matches
        ReactMenu menu = menus.get(e.getMessageIdLong());
        boolean removed = false;
        if (menu.getOwnerID() == e.getUserIdLong()) {
            // Make sure emote matches
            HashMap<String, Runnable> buttons = menu.getButtons();
            ReactionEmote re = e.getReactionEmote();
            if (e.getReactionEmote().isEmoji()) {
                String emote = re.getAsCodepoints();
                if (buttons.containsKey(emote)) {
                    // Run the code
                    removeEmote(e);
                    removed = true;
                    Runnable r = buttons.get(emote);
                    if (r != null) {
                        menu.keepAlive();
                        r.run();
                    }
                }
            }
        }
        if (!e.getUser().isBot() && !removed) {
            removeEmote(e);
        }
    }
}
Also used : ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote)

Example 3 with ReactionEmote

use of net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote in project Sx4 by sx4-discord-bot.

the class StarboardCommand method emote.

@Command(value = "emote", aliases = { "emoji" }, description = "Sets the emote/emoji to be used for starboard")
@CommandId(199)
@Examples({ "starboard emote ☝️", "starboard emote <:upvote:761345612079693865>", "starboard emote reset" })
@AuthorPermissions(permissions = { Permission.MANAGE_SERVER })
public void emote(Sx4CommandEvent event, @Argument(value = "emote | reset", endless = true) @AlternativeOptions("reset") Alternative<ReactionEmote> option) {
    ReactionEmote emote = option.getValue();
    boolean emoji = emote != null && emote.isEmoji();
    List<Bson> update = emote == null ? List.of(Operators.unset("starboard.emote")) : List.of(Operators.set("starboard.emote." + (emoji ? "name" : "id"), emoji ? emote.getEmoji() : emote.getIdLong()), Operators.unset("starboard.emote." + (emoji ? "id" : "name")));
    FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.BEFORE).upsert(true).projection(Projections.include("starboard.emote"));
    event.getMongo().findAndUpdateGuildById(event.getGuild().getIdLong(), update, options).whenComplete((data, exception) -> {
        if (ExceptionUtility.sendExceptionally(event, exception)) {
            return;
        }
        Document emoteData = data == null ? null : data.getEmbedded(List.of("starboard", "emote"), Document.class);
        if ((emote == null && emoteData == null) || (emote != null && emoteData != null && (emoji ? emote.getEmoji().equals(emoteData.getString("name")) : emoteData.getLong("id") == emote.getIdLong()))) {
            event.replyFailure("Your starboard emote was already " + (emote == null ? "unset" : "set to that")).queue();
            return;
        }
        event.replySuccess("Your starboard emote has been " + (emote == null ? "unset" : "updated")).queue();
    });
}
Also used : Document(org.bson.Document) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) Bson(org.bson.conversions.Bson) Command(com.jockie.bot.core.command.Command) Sx4Command(com.sx4.bot.core.Sx4Command)

Example 4 with ReactionEmote

use of net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote in project Sx4 by sx4-discord-bot.

the class ReactionRoleHandler method onGenericGuildMessageReaction.

public void onGenericGuildMessageReaction(GenericGuildMessageReactionEvent event) {
    User user = event.getUser();
    Guild guild = event.getGuild();
    ReactionEmote emote = event.getReactionEmote();
    if (user == null || user.isBot()) {
        return;
    }
    Config config = this.bot.getConfig();
    List<Document> reactionRoles = this.bot.getMongo().getReactionRoles(Filters.eq("messageId", event.getMessageIdLong()), MongoDatabase.EMPTY_DOCUMENT).into(new ArrayList<>());
    if (reactionRoles.isEmpty()) {
        return;
    }
    if (!guild.getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
        user.openPrivateChannel().flatMap(channel -> channel.sendMessage("I am missing the `" + Permission.MANAGE_ROLES.getName() + "` permission " + config.getFailureEmote())).queue(null, ErrorResponseException.ignore(ErrorResponse.CANNOT_SEND_TO_USER));
        return;
    }
    int reactedTo = 0;
    List<Role> roles = null;
    Document reactionRole = null;
    boolean remove = false;
    Set<Role> memberRoles = new HashSet<>(event.getMember().getRoles());
    for (Document data : reactionRoles) {
        List<Role> rolesData = data.getList("roles", Long.class).stream().map(guild::getRoleById).filter(Objects::nonNull).filter(role -> guild.getSelfMember().canInteract(role)).collect(Collectors.toList());
        boolean allRoles = memberRoles.containsAll(rolesData);
        if (allRoles) {
            reactedTo++;
        }
        Document emoteData = data.get("emote", Document.class);
        if ((emote.isEmoji() && emoteData.containsKey("name") && emoteData.getString("name").equals(emote.getEmoji())) || (emote.isEmote() && emoteData.containsKey("id") && emoteData.getLong("id") == emote.getEmote().getIdLong())) {
            if (rolesData.isEmpty()) {
                return;
            }
            roles = rolesData;
            reactionRole = data;
            remove = allRoles;
        }
    }
    if (roles == null) {
        return;
    }
    if (!remove) {
        List<Document> permissions = reactionRole.getList("permissions", Document.class, Collections.emptyList());
        for (int i = 0; i < permissions.size(); i++) {
            Document permission = permissions.get(i);
            long holderId = permission.getLong("id");
            int type = permission.getInteger("type");
            boolean granted = permission.getBoolean("granted");
            if (type == HolderType.USER.getType() && holderId == user.getIdLong()) {
                if (granted) {
                    break;
                }
            } else if (type == HolderType.ROLE.getType() && (holderId == guild.getIdLong() || memberRoles.stream().anyMatch(role -> role.getIdLong() == holderId))) {
                if (granted) {
                    break;
                }
            }
            if (i == permissions.size() - 1) {
                user.openPrivateChannel().flatMap(channel -> channel.sendMessage("You are not whitelisted to be able to get the roles behind this reaction " + config.getFailureEmote())).queue(null, ErrorResponseException.ignore(ErrorResponse.CANNOT_SEND_TO_USER));
                return;
            }
        }
    }
    int maxReactions = reactionRole.get("maxReactions", 0);
    if (!remove && reactedTo >= maxReactions && maxReactions != 0) {
        user.openPrivateChannel().flatMap(channel -> channel.sendMessage("You can only react to **" + maxReactions + "** reaction" + (maxReactions == 1 ? "" : "s") + " on this message " + config.getFailureEmote())).queue(null, ErrorResponseException.ignore(ErrorResponse.CANNOT_SEND_TO_USER));
        return;
    }
    if (remove) {
        guild.modifyMemberRoles(event.getMember(), null, roles).queue();
    } else {
        guild.modifyMemberRoles(event.getMember(), roles, null).queue();
    }
    String message = "You " + (remove ? "no longer" : "now") + " have the role" + (roles.size() == 1 ? "" : "s") + " `" + roles.stream().map(Role::getName).collect(Collectors.joining("`, `")) + "` " + config.getSuccessEmote();
    if (reactionRole.getBoolean("dm", true)) {
        user.openPrivateChannel().flatMap(channel -> channel.sendMessage(message)).queue(null, ErrorResponseException.ignore(ErrorResponse.CANNOT_SEND_TO_USER));
    }
}
Also used : HolderType(com.sx4.bot.entities.settings.HolderType) MessageBulkDeleteEvent(net.dv8tion.jda.api.events.message.MessageBulkDeleteEvent) Document(org.bson.Document) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) java.util(java.util) MongoWriteException(com.mongodb.MongoWriteException) Permission(net.dv8tion.jda.api.Permission) MongoDatabase(com.sx4.bot.database.mongo.MongoDatabase) ErrorResponse(net.dv8tion.jda.api.requests.ErrorResponse) User(net.dv8tion.jda.api.entities.User) Filters(com.mongodb.client.model.Filters) Guild(net.dv8tion.jda.api.entities.Guild) Sx4(com.sx4.bot.core.Sx4) Role(net.dv8tion.jda.api.entities.Role) GenericEvent(net.dv8tion.jda.api.events.GenericEvent) UpdateOptions(com.mongodb.client.model.UpdateOptions) GenericGuildMessageReactionEvent(net.dv8tion.jda.api.events.message.guild.react.GenericGuildMessageReactionEvent) Config(com.sx4.bot.config.Config) ErrorResponseException(net.dv8tion.jda.api.exceptions.ErrorResponseException) Updates(com.mongodb.client.model.Updates) CompletionException(java.util.concurrent.CompletionException) Collectors(java.util.stream.Collectors) EventListener(net.dv8tion.jda.api.hooks.EventListener) MessageDeleteEvent(net.dv8tion.jda.api.events.message.MessageDeleteEvent) RoleDeleteEvent(net.dv8tion.jda.api.events.role.RoleDeleteEvent) ExceptionUtility(com.sx4.bot.utility.ExceptionUtility) NotNull(org.jetbrains.annotations.NotNull) User(net.dv8tion.jda.api.entities.User) Config(com.sx4.bot.config.Config) Guild(net.dv8tion.jda.api.entities.Guild) Document(org.bson.Document) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) Role(net.dv8tion.jda.api.entities.Role)

Example 5 with ReactionEmote

use of net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote in project cds by iamysko.

the class ReactionListener method onMessageReactionAdd.

/**
 * On message reaction add.
 *
 * @param event the event
 */
@Override
public void onMessageReactionAdd(final MessageReactionAddEvent event) {
    final TextChannel commandChannel = event.getGuild().getTextChannelById(Properties.CHANNEL_COMMANDS_ID);
    final MessageReaction reaction = event.getReaction();
    final Member reactee = event.getMember();
    final MessageChannel channel = event.getTextChannel();
    final ReactionEmote emote = reaction.getReactionEmote();
    final String emoteId = emote.isEmote() ? emote.getId() : "";
    if (!emoteId.equals(ID_REACTION_ALERT_MODS) && !RoleUtils.isAnyRole(reactee, RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_MODERATOR, RoleUtils.ROLE_SENIOR_MODERATOR, RoleUtils.ROLE_TRIAL_MODERATOR, RoleUtils.ROLE_BOT)) {
        // Do nothing.
        return;
    }
    event.retrieveMessage().queue(message -> {
        final String messageLink = message.getJumpUrl();
        message.getJDA().getGuildById(message.getGuild().getIdLong()).retrieveMemberById(message.getAuthor().getId()).queue(messageAuthor -> {
            if (emoteId.equals(ID_REACTION_ALERT_MODS)) {
                if (existingAlertsMap.get(message.getIdLong()) == null) {
                    alertMods(event.getGuild().getTextChannelById(Properties.CHANNEL_MOD_ALERTS_ID), reactee, message, messageAuthor, Instant.now());
                }
            }
            if (!RoleUtils.isAnyRole(reactee, RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_MODERATOR, RoleUtils.ROLE_SENIOR_MODERATOR, RoleUtils.ROLE_TRIAL_MODERATOR, RoleUtils.ROLE_BOT)) {
                // Do nothing.
                return;
            }
            final Action commandAction = new Action();
            commandAction.setDate(Instant.now());
            commandAction.setUser(reactee.getUser().getAsTag());
            commandAction.setDiscordId(reactee.getIdLong());
            switch(emoteId) {
                case ID_REACTION_PURGE_MESSAGES:
                    if (!isStaffOnStaff(reactee, messageAuthor, commandChannel) && !isInStaffChannel(reactee, commandChannel, event.getChannel()) && RoleUtils.isAnyRole(event.getMember(), RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_MODERATOR, RoleUtils.ROLE_TRIAL_MODERATOR, RoleUtils.ROLE_BOT)) {
                        purgeMessagesInChannel(messageAuthor, channel);
                        commandAction.setOffendingUser(messageAuthor.getUser().getAsTag());
                        commandAction.setOffendingUserId(messageAuthor.getIdLong());
                        commandAction.setActionType("REACTION_PURGE_MESSAGES");
                        log.info("[Reaction Command] Message purge executed by {} on {}", reactee.getUser().getAsTag(), messageAuthor.getUser().getAsTag());
                    }
                    break;
                case ID_REACTION_QM_30:
                    if (reactee.getIdLong() != messageAuthor.getIdLong()) {
                        if (RoleUtils.isAnyRole(reactee, RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_MODERATOR, RoleUtils.ROLE_BOT)) {
                            if (event.getChannel().getIdLong() == Properties.CHANNEL_CENSORED_AND_SPAM_LOGS_ID || event.getChannel().getIdLong() == Properties.CHANNEL_MESSAGE_LOGS_ID) {
                                quickMuteFromLogs(reactee, message, commandChannel, "30m");
                                log.info("[Reaction Command] 30m Quick-Mute executed by {} ({}) (message: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                            } else if (event.getChannel().getIdLong() != Properties.CHANNEL_MOD_ALERTS_ID) {
                                if (!isStaffOnStaff(reactee, messageAuthor, commandChannel)) {
                                    muteUser(reactee, messageAuthor, "30m", message, commandChannel);
                                    purgeMessagesInChannel(messageAuthor, channel);
                                    commandAction.setOffendingUser(messageAuthor.getUser().getAsTag());
                                    commandAction.setOffendingUserId(messageAuthor.getIdLong());
                                    commandAction.setActionType("REACTION_QM_30");
                                    log.info("[Reaction Command] 30m Quick-Mute executed by {} on {}", reactee.getUser().getAsTag(), messageAuthor.getUser().getAsTag());
                                    deleteModAlert(messageLink, event);
                                }
                            } else {
                                final String rawMessage = message.getContentRaw();
                                final String channelId = rawMessage.split("/")[5];
                                final String messageId = rawMessage.split("/")[6];
                                final String authorId = rawMessage.split("`")[3];
                                event.getGuild().getTextChannelById(channelId).retrieveMessageById(messageId).queue(alertmessage -> {
                                    event.getGuild().retrieveMemberById(authorId).queue((author) -> {
                                        if (!isStaffOnStaff(reactee, author, commandChannel)) {
                                            muteUser(reactee, author, "30m", alertmessage, commandChannel);
                                            purgeMessagesInChannel(author, event.getGuild().getTextChannelById(channelId));
                                        }
                                    });
                                }, alertfailure -> {
                                    commandChannel.sendMessage(new StringBuilder().append(reactee.getAsMention()).append(" the message does not exist or action has already been taken.")).queue();
                                });
                                if (reactee.getIdLong() != messageAuthor.getIdLong()) {
                                    clearAlert(commandChannel, event.getGuild().getTextChannelById(Properties.CHANNEL_MOD_ALERTS_ID), reactee, message, messageAuthor, Instant.now());
                                    commandAction.setActionType("REACTION_ALERT_DONE");
                                    log.info("[Reaction Command] Mod alert marked done by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                                }
                            }
                        }
                    }
                    break;
                case ID_REACTION_QM_60:
                    if (reactee.getIdLong() != messageAuthor.getIdLong()) {
                        if (RoleUtils.isAnyRole(reactee, RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_MODERATOR, RoleUtils.ROLE_BOT)) {
                            if (event.getChannel().getIdLong() == Properties.CHANNEL_CENSORED_AND_SPAM_LOGS_ID || event.getChannel().getIdLong() == Properties.CHANNEL_MESSAGE_LOGS_ID) {
                                quickMuteFromLogs(reactee, message, commandChannel, "1h");
                                log.info("[Reaction Command] 1h Quick-Mute executed by {} ({}) (message: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                            } else if (event.getChannel().getIdLong() != Properties.CHANNEL_MOD_ALERTS_ID) {
                                if (!isStaffOnStaff(reactee, messageAuthor, commandChannel)) {
                                    muteUser(reactee, messageAuthor, "1h", message, commandChannel);
                                    purgeMessagesInChannel(messageAuthor, channel);
                                    commandAction.setOffendingUser(messageAuthor.getUser().getAsTag());
                                    commandAction.setOffendingUserId(messageAuthor.getIdLong());
                                    commandAction.setActionType("REACTION_QM_60");
                                    log.info("[Reaction Command] 1h Quick-Mute executed by {} on {}", reactee.getUser().getAsTag(), messageAuthor.getUser().getAsTag());
                                    deleteModAlert(messageLink, event);
                                }
                            } else {
                                final String rawMessage = message.getContentRaw();
                                final String channelId = rawMessage.split("/")[5];
                                final String messageId = rawMessage.split("/")[6];
                                final String authorId = rawMessage.split("`")[3];
                                event.getGuild().getTextChannelById(channelId).retrieveMessageById(messageId).queue(alertmessage -> {
                                    event.getGuild().retrieveMemberById(authorId).queue((author) -> {
                                        if (!isStaffOnStaff(reactee, author, commandChannel)) {
                                            muteUser(reactee, author, "60m", alertmessage, commandChannel);
                                            purgeMessagesInChannel(author, event.getGuild().getTextChannelById(channelId));
                                        }
                                    });
                                }, alertfailure -> {
                                    commandChannel.sendMessage(new StringBuilder().append(reactee.getAsMention()).append(" the message does not exist or action has already been taken.")).queue();
                                });
                                if (reactee.getIdLong() != messageAuthor.getIdLong()) {
                                    clearAlert(commandChannel, event.getGuild().getTextChannelById(Properties.CHANNEL_MOD_ALERTS_ID), reactee, message, messageAuthor, Instant.now());
                                    commandAction.setActionType("REACTION_ALERT_DONE");
                                    log.info("[Reaction Command] Mod alert marked done by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                                }
                            }
                        }
                    }
                    break;
                case // Used for ban requests, filtered log bans, and mod alerts.
                ID_REACTION_APPROVE:
                    if (RoleUtils.isAnyRole(event.getMember(), RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_SENIOR_MODERATOR)) {
                        if (event.getChannel().getIdLong() == Properties.CHANNEL_MOD_ALERTS_ID) {
                            if (reactee.getIdLong() != messageAuthor.getIdLong()) {
                                clearAlert(commandChannel, event.getGuild().getTextChannelById(Properties.CHANNEL_MOD_ALERTS_ID), reactee, message, messageAuthor, Instant.now());
                                commandAction.setActionType("REACTION_ALERT_DONE");
                                log.info("[Reaction Command] Mod alert marked done by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                            }
                        }
                        if (event.getChannel().getIdLong() == Properties.CHANNEL_BAN_REQUESTS_QUEUE_ID) {
                            approveBanRequest(reactee, message, commandChannel);
                            commandAction.setActionType("REACTION_APPROVE_BAN_REQUEST");
                            log.info("[Reaction Command] Ban request approved by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                        } else if (event.getChannel().getIdLong() == Properties.CHANNEL_CENSORED_AND_SPAM_LOGS_ID || event.getChannel().getIdLong() == Properties.CHANNEL_MESSAGE_LOGS_ID) {
                            approveLogsBan(reactee, message, commandChannel);
                            commandAction.setActionType("REACTION_APPROVE_BAN_REQUEST");
                            log.info("[Reaction Command] Logs message ban approved by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                        }
                    } else if (RoleUtils.isAnyRole(event.getMember(), RoleUtils.ROLE_MODERATOR, RoleUtils.ROLE_TRIAL_MODERATOR)) {
                        if (event.getChannel().getIdLong() == Properties.CHANNEL_MOD_ALERTS_ID) {
                            clearAlert(commandChannel, event.getGuild().getTextChannelById(Properties.CHANNEL_MOD_ALERTS_ID), reactee, message, messageAuthor, Instant.now());
                            commandAction.setActionType("REACTION_ALERT_DONE");
                            log.info("[Reaction Command] Mod alert marked done by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                        }
                    }
                    break;
                case ID_REACTION_REJECT:
                    if (event.getChannel().getIdLong() == Properties.CHANNEL_BAN_REQUESTS_QUEUE_ID && RoleUtils.isAnyRole(event.getMember(), RoleUtils.ROLE_SERVER_MANAGER, RoleUtils.ROLE_SENIOR_MODERATOR)) {
                        rejectBanRequest(reactee, message, commandChannel);
                        commandAction.setActionType("REACTION_REJECT_BAN_REQUEST");
                        log.info("[Reaction Command] Ban request rejected by {} ({}) (request: {})", reactee.getEffectiveName(), reactee.getId(), message.getJumpUrl());
                    }
                    break;
                default:
                    // Do nothing.
                    return;
            }
            cdsData.insertAction(commandAction);
        });
    }, (failure) -> {
        log.error("An error occurred obtaining a reaction event's message. Details: {}", failure.getMessage());
    });
}
Also used : ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) Action(com.misterveiga.cds.entities.Action) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) RoleUtils(com.misterveiga.cds.utils.RoleUtils) Properties(com.misterveiga.cds.utils.Properties) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) PropertySource(org.springframework.context.annotation.PropertySource) Member(net.dv8tion.jda.api.entities.Member) TextChannel(net.dv8tion.jda.api.entities.TextChannel) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) User(net.dv8tion.jda.api.entities.User) Message(net.dv8tion.jda.api.entities.Message) Logger(org.slf4j.Logger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ListenerAdapter(net.dv8tion.jda.api.hooks.ListenerAdapter) Instant(java.time.Instant) MessageReactionAddEvent(net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Component(org.springframework.stereotype.Component) ChronoUnit(java.time.temporal.ChronoUnit) CdsDataImpl(com.misterveiga.cds.data.CdsDataImpl) MentionType(net.dv8tion.jda.api.entities.Message.MentionType) MessageReaction(net.dv8tion.jda.api.entities.MessageReaction) MessageReaction(net.dv8tion.jda.api.entities.MessageReaction) TextChannel(net.dv8tion.jda.api.entities.TextChannel) Action(com.misterveiga.cds.entities.Action) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) Member(net.dv8tion.jda.api.entities.Member) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote)

Aggregations

ReactionEmote (net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote)9 NotNull (org.jetbrains.annotations.NotNull)6 Document (org.bson.Document)5 MongoWriteException (com.mongodb.MongoWriteException)4 Sx4 (com.sx4.bot.core.Sx4)4 MongoDatabase (com.sx4.bot.database.mongo.MongoDatabase)4 ExceptionUtility (com.sx4.bot.utility.ExceptionUtility)4 List (java.util.List)4 CompletionException (java.util.concurrent.CompletionException)4 WebhookEmbed (club.minnced.discord.webhook.send.WebhookEmbed)3 WebhookEmbedBuilder (club.minnced.discord.webhook.send.WebhookEmbedBuilder)3 WebhookMessage (club.minnced.discord.webhook.send.WebhookMessage)3 WebhookMessageBuilder (club.minnced.discord.webhook.send.WebhookMessageBuilder)3 ErrorCategory (com.mongodb.ErrorCategory)3 com.mongodb.client.model (com.mongodb.client.model)3 Operators (com.sx4.bot.database.mongo.model.Operators)3 Formatter (com.sx4.bot.formatter.Formatter)3 JsonFormatter (com.sx4.bot.formatter.JsonFormatter)3 StarboardManager (com.sx4.bot.managers.StarboardManager)3 MessageUtility (com.sx4.bot.utility.MessageUtility)3