Search in sources :

Example 1 with Config

use of com.sx4.bot.config.Config in project Sx4 by sx4-discord-bot.

the class WarnCommand method set.

@Command(value = "set", description = "Set the amount of warns a user has")
@CommandId(242)
@Redirects({ "set warns", "set warnings" })
@Examples({ "warn set @Shea#6653 2", "warn set Shea#6653 0", "warn set 402557516728369153 1" })
@AuthorPermissions(permissions = { Permission.MANAGE_SERVER })
public void set(Sx4CommandEvent event, @Argument(value = "user") Member member, @Argument(value = "warnings") int warnings) {
    if (member.canInteract(event.getMember())) {
        event.replyFailure("You cannot change the amount of warnings of someone higher or equal than your top role").queue();
        return;
    }
    Document warnData = event.getMongo().getGuildById(event.getGuild().getIdLong(), Projections.include("warn")).get("warn", MongoDatabase.EMPTY_DOCUMENT);
    boolean punishments = warnData.get("punishments", true);
    int maxWarning = punishments ? warnData.getList("config", Document.class, Warn.DEFAULT_CONFIG).stream().map(d -> d.getInteger("number")).max(Integer::compareTo).get() : Integer.MAX_VALUE;
    if (warnings > maxWarning) {
        event.replyFailure("The max amount of warnings you can give is **" + maxWarning + "**").queue();
        return;
    }
    Bson update = warnings == 0 ? Updates.unset("warnings") : Updates.combine(Updates.set("warnings", warnings), Updates.set("lastWarning", Clock.systemUTC().instant().getEpochSecond()));
    Bson filter = Filters.and(Filters.eq("userId", member.getIdLong()), Filters.eq("guildId", event.getGuild().getIdLong()));
    event.getMongo().updateWarnings(filter, update, new UpdateOptions().upsert(true)).whenComplete((result, exception) -> {
        if (ExceptionUtility.sendExceptionally(event, exception)) {
            return;
        }
        if (result.getModifiedCount() == 0 && result.getUpsertedId() == null) {
            event.replyFailure("That user already had that amount of warnings").queue();
            return;
        }
        event.replySuccess("That user now has **" + warnings + "** warning" + (warnings == 1 ? "" : "s")).queue();
    });
}
Also used : Document(org.bson.Document) MarkdownSanitizer(net.dv8tion.jda.api.utils.MarkdownSanitizer) Command(com.jockie.bot.core.command.Command) Permission(net.dv8tion.jda.api.Permission) MongoDatabase(com.sx4.bot.database.mongo.MongoDatabase) ModAction(com.sx4.bot.entities.mod.action.ModAction) Member(net.dv8tion.jda.api.entities.Member) TimedArgument(com.sx4.bot.entities.argument.TimedArgument) PagedResult(com.sx4.bot.paged.PagedResult) User(net.dv8tion.jda.api.entities.User) ArrayList(java.util.ArrayList) TimeAction(com.sx4.bot.entities.mod.action.TimeAction) Bson(org.bson.conversions.Bson) Alternative(com.sx4.bot.entities.argument.Alternative) Sx4CommandEvent(com.sx4.bot.core.Sx4CommandEvent) TimeUtility(com.sx4.bot.utility.TimeUtility) Duration(java.time.Duration) AlternativeOptions(com.sx4.bot.annotations.argument.AlternativeOptions) Reason(com.sx4.bot.entities.mod.Reason) com.mongodb.client.model(com.mongodb.client.model) com.sx4.bot.annotations.command(com.sx4.bot.annotations.command) Warn(com.sx4.bot.entities.mod.action.Warn) Argument(com.jockie.bot.core.argument.Argument) Limit(com.sx4.bot.annotations.argument.Limit) Action(com.sx4.bot.entities.mod.action.Action) Operators(com.sx4.bot.database.mongo.model.Operators) Sx4Command(com.sx4.bot.core.Sx4Command) NumberUtility(com.sx4.bot.utility.NumberUtility) ModUtility(com.sx4.bot.utility.ModUtility) CompletionException(java.util.concurrent.CompletionException) ModuleCategory(com.sx4.bot.category.ModuleCategory) List(java.util.List) Clock(java.time.Clock) ExceptionUtility(com.sx4.bot.utility.ExceptionUtility) Comparator(java.util.Comparator) Document(org.bson.Document) Bson(org.bson.conversions.Bson) Command(com.jockie.bot.core.command.Command) Sx4Command(com.sx4.bot.core.Sx4Command)

Example 2 with Config

use of com.sx4.bot.config.Config 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 3 with Config

use of com.sx4.bot.config.Config in project Sx4 by sx4-discord-bot.

the class ModUtility method warn.

public static CompletableFuture<WarnAction> warn(Sx4 bot, Member target, Member moderator, Reason reason) {
    CompletableFuture<WarnAction> future = new CompletableFuture<>();
    Guild guild = target.getGuild();
    Document data = bot.getMongo().getGuildById(guild.getIdLong(), Projections.include("warn", "mute", "temporaryBan", "fakePermissions"));
    List<Document> fakePermissions = data.getEmbedded(List.of("fakePermissions", "holders"), Collections.emptyList());
    Document warnData = data.get("warn", MongoDatabase.EMPTY_DOCUMENT);
    List<Document> config = warnData.getList("config", Document.class, Warn.DEFAULT_CONFIG);
    boolean punishments = warnData.getBoolean("punishments", true);
    Document reset = warnData.get("reset", Document.class);
    int maxWarning = punishments ? config.stream().map(d -> d.getInteger("number")).max(Integer::compareTo).get() : Integer.MAX_VALUE;
    List<Bson> update = List.of(Operators.set("warnings", Operators.let(new Document("warnings", Operators.ifNull("$warnings", 0)), Operators.mod(Operators.cond(Operators.exists("$reset"), Operators.max(1, Operators.add(1, Operators.subtract("$$warnings", Operators.multiply(Operators.toInt(Operators.floor(Operators.divide(Operators.subtract(Operators.nowEpochSecond(), "$lastWarning"), "$reset.after"))), "$reset.amount")))), Operators.add("$$warnings", 1)), maxWarning))), Operators.set("lastWarning", Operators.nowEpochSecond()), reset == null ? Operators.unset("reset") : Operators.set("reset", reset));
    FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER).projection(Projections.include("warnings")).upsert(true);
    Bson filter = Filters.and(Filters.eq("userId", target.getIdLong()), Filters.eq("guildId", guild.getIdLong()));
    bot.getMongo().findAndUpdateWarnings(filter, update, options).whenComplete((result, exception) -> {
        if (exception != null) {
            future.completeExceptionally(exception);
            return;
        }
        int warnings = result.getInteger("warnings");
        Action warnAction = new Action(ModAction.WARN);
        Action currentAction = warnAction, nextAction = warnAction;
        if (punishments) {
            for (Document configData : config) {
                int number = configData.getInteger("number");
                if (number == warnings) {
                    currentAction = Action.fromData(configData.get("action", Document.class));
                } else if (number == warnings + 1) {
                    nextAction = Action.fromData(configData.get("action", Document.class));
                }
            }
        }
        Action action = currentAction;
        Warn currentWarning = new Warn(action, warnings);
        Warn nextWarning = new Warn(nextAction, warnings + 1);
        switch(action.getModAction()) {
            case WARN:
                bot.getModActionManager().onModAction(new WarnEvent(moderator, target.getUser(), reason, currentWarning, nextWarning));
                future.complete(new WarnAction(currentWarning));
                break;
            case MUTE_EXTEND:
            case MUTE:
                if (!guild.getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
                    future.completeExceptionally(new BotPermissionException(Permission.MANAGE_ROLES));
                    return;
                }
                AtomicReference<Role> atomicRole = new AtomicReference<>();
                Document mute = data.get("mute", MongoDatabase.EMPTY_DOCUMENT);
                long muteDuration = ((TimeAction) action).getDuration();
                boolean extend = action.getModAction().isExtend();
                ModUtility.upsertMuteRole(bot.getMongo(), guild, mute.get("roleId", 0L), mute.get("autoUpdate", true)).thenCompose(role -> {
                    atomicRole.set(role);
                    List<Bson> muteUpdate = List.of(Operators.set("unmuteAt", Operators.add(muteDuration, Operators.cond(Operators.and(extend, Operators.exists("$unmuteAt")), "$unmuteAt", Operators.nowEpochSecond()))));
                    Bson muteFilter = Filters.and(Filters.eq("userId", target.getIdLong()), Filters.eq("guildId", guild.getIdLong()));
                    return bot.getMongo().updateMute(muteFilter, muteUpdate, new UpdateOptions().upsert(true));
                }).whenComplete((muteResult, muteException) -> {
                    if (muteException != null) {
                        future.completeExceptionally(muteException);
                        return;
                    }
                    Role role = atomicRole.get();
                    guild.addRoleToMember(target, role).reason(ModUtility.getAuditReason(reason, moderator.getUser())).queue($ -> {
                        bot.getMuteManager().putMute(guild.getIdLong(), target.getIdLong(), role.getIdLong(), muteDuration, extend && muteResult.getUpsertedId() == null);
                        bot.getModActionManager().onModAction(new WarnEvent(moderator, target.getUser(), reason, currentWarning, nextWarning));
                        future.complete(new WarnAction(currentWarning));
                    });
                });
                break;
            case KICK:
                if (!guild.getSelfMember().hasPermission(Permission.KICK_MEMBERS)) {
                    future.completeExceptionally(new BotPermissionException(Permission.KICK_MEMBERS));
                    return;
                }
                if (!guild.getSelfMember().canInteract(target)) {
                    future.completeExceptionally(new BotHierarchyException("kick"));
                    return;
                }
                if (!CheckUtility.hasPermissions(bot, moderator, fakePermissions, Permission.KICK_MEMBERS)) {
                    future.completeExceptionally(new AuthorPermissionException(Permission.KICK_MEMBERS));
                    return;
                }
                target.kick(ModUtility.getAuditReason(reason, moderator.getUser())).queue($ -> {
                    bot.getModActionManager().onModAction(new WarnEvent(moderator, target.getUser(), reason, currentWarning, nextWarning));
                    future.complete(new WarnAction(currentWarning));
                });
                break;
            case TEMPORARY_BAN:
                if (!guild.getSelfMember().hasPermission(Permission.BAN_MEMBERS)) {
                    future.completeExceptionally(new BotPermissionException(Permission.BAN_MEMBERS));
                    return;
                }
                if (!guild.getSelfMember().canInteract(target)) {
                    future.completeExceptionally(new BotHierarchyException("ban"));
                    return;
                }
                if (!CheckUtility.hasPermissions(bot, moderator, fakePermissions, Permission.BAN_MEMBERS)) {
                    future.completeExceptionally(new AuthorPermissionException(Permission.BAN_MEMBERS));
                    return;
                }
                long temporaryBanDuration = ((TimeAction) action).getDuration();
                Bson temporaryBanUpdate = Updates.set("unbanAt", Clock.systemUTC().instant().getEpochSecond() + temporaryBanDuration);
                Bson temporaryBanFilter = Filters.and(Filters.eq("userId", target.getIdLong()), Filters.eq("guildId", guild.getIdLong()));
                bot.getMongo().updateTemporaryBan(temporaryBanFilter, temporaryBanUpdate, new UpdateOptions().upsert(true)).whenComplete((temporaryBanResult, temporaryBanException) -> {
                    if (temporaryBanException != null) {
                        future.completeExceptionally(temporaryBanException);
                        return;
                    }
                    target.ban(1).reason(ModUtility.getAuditReason(reason, moderator.getUser())).queue($ -> {
                        bot.getModActionManager().onModAction(new WarnEvent(moderator, target.getUser(), reason, currentWarning, nextWarning));
                        bot.getTemporaryBanManager().putBan(guild.getIdLong(), target.getIdLong(), ((TimeAction) action).getDuration());
                        future.complete(new WarnAction(currentWarning));
                    });
                });
                break;
            case BAN:
                if (!guild.getSelfMember().hasPermission(Permission.BAN_MEMBERS)) {
                    future.completeExceptionally(new BotPermissionException(Permission.BAN_MEMBERS));
                    return;
                }
                if (!guild.getSelfMember().canInteract(target)) {
                    future.completeExceptionally(new BotHierarchyException("ban"));
                    return;
                }
                if (!CheckUtility.hasPermissions(bot, moderator, fakePermissions, Permission.BAN_MEMBERS)) {
                    future.completeExceptionally(new AuthorPermissionException(Permission.BAN_MEMBERS));
                    return;
                }
                target.ban(1).reason(ModUtility.getAuditReason(reason, moderator.getUser())).queue($ -> {
                    bot.getModActionManager().onModAction(new WarnEvent(moderator, target.getUser(), reason, currentWarning, nextWarning));
                    future.complete(new WarnAction(currentWarning));
                });
                break;
            default:
                break;
        }
    });
    return future;
}
Also used : Document(org.bson.Document) Operators(com.sx4.bot.database.mongo.model.Operators) BotPermissionException(com.sx4.bot.exceptions.mod.BotPermissionException) com.sx4.bot.entities.mod.action(com.sx4.bot.entities.mod.action) Permission(net.dv8tion.jda.api.Permission) MongoDatabase(com.sx4.bot.database.mongo.MongoDatabase) CompletableFuture(java.util.concurrent.CompletableFuture) MaxRolesException(com.sx4.bot.exceptions.mod.MaxRolesException) Member(net.dv8tion.jda.api.entities.Member) AuthorPermissionException(com.sx4.bot.exceptions.mod.AuthorPermissionException) BotHierarchyException(com.sx4.bot.exceptions.mod.BotHierarchyException) AtomicReference(java.util.concurrent.atomic.AtomicReference) User(net.dv8tion.jda.api.entities.User) Bson(org.bson.conversions.Bson) List(java.util.List) Guild(net.dv8tion.jda.api.entities.Guild) Sx4(com.sx4.bot.core.Sx4) Role(net.dv8tion.jda.api.entities.Role) Duration(java.time.Duration) Reason(com.sx4.bot.entities.mod.Reason) Clock(java.time.Clock) com.sx4.bot.events.mod(com.sx4.bot.events.mod) com.mongodb.client.model(com.mongodb.client.model) Collections(java.util.Collections) Guild(net.dv8tion.jda.api.entities.Guild) Document(org.bson.Document) Bson(org.bson.conversions.Bson) CompletableFuture(java.util.concurrent.CompletableFuture) BotPermissionException(com.sx4.bot.exceptions.mod.BotPermissionException) List(java.util.List) BotHierarchyException(com.sx4.bot.exceptions.mod.BotHierarchyException) AuthorPermissionException(com.sx4.bot.exceptions.mod.AuthorPermissionException) AtomicReference(java.util.concurrent.atomic.AtomicReference) Role(net.dv8tion.jda.api.entities.Role)

Example 4 with Config

use of com.sx4.bot.config.Config in project Sx4 by sx4-discord-bot.

the class StarboardHandler method onGuildMessageReactionRemove.

public void onGuildMessageReactionRemove(GuildMessageReactionRemoveEvent event) {
    User user = event.getUser();
    if (user == null || user.isBot()) {
        return;
    }
    List<Bson> starboardPipeline = List.of(Aggregates.match(Filters.or(Filters.eq("originalMessageId", event.getMessageIdLong()), Filters.eq("messageId", event.getMessageIdLong()))), Aggregates.project(Projections.include("originalMessageId", "messageId", "count")));
    List<Bson> pipeline = List.of(Aggregates.match(Filters.eq("_id", event.getGuild().getIdLong())), Aggregates.project(Projections.fields(Projections.include("starboard"), Projections.computed("premium", Operators.lt(Operators.nowEpochSecond(), Operators.ifNull("$premium.endAt", 0L))))), Aggregates.unionWith("starboards", starboardPipeline), Aggregates.group(null, Accumulators.max("count", "$count"), Accumulators.max("messageId", "$messageId"), Accumulators.max("originalMessageId", "$originalMessageId"), Accumulators.max("starboard", "$starboard"), Accumulators.max("premium", "$premium")));
    this.bot.getMongo().aggregateGuilds(pipeline).whenComplete((documents, aggregateException) -> {
        if (ExceptionUtility.sendErrorMessage(aggregateException)) {
            return;
        }
        if (documents.isEmpty()) {
            return;
        }
        Document data = documents.get(0);
        Document starboard = data.get("starboard", MongoDatabase.EMPTY_DOCUMENT);
        if (!starboard.get("enabled", false)) {
            return;
        }
        long channelId = starboard.get("channelId", 0L);
        TextChannel channel = channelId == 0L ? null : event.getGuild().getTextChannelById(channelId);
        if (channel == null) {
            return;
        }
        ReactionEmote emote = event.getReactionEmote();
        boolean emoji = emote.isEmoji();
        Document emoteData = starboard.get("emote", new Document("name", "⭐"));
        if ((emoji && !emote.getEmoji().equals(emoteData.getString("name"))) || (!emoji && (!emoteData.containsKey("id") || emoteData.getLong("id") != emote.getIdLong()))) {
            return;
        }
        Long originalMessageId = data.getLong("originalMessageId");
        if (originalMessageId == null) {
            return;
        }
        List<Document> config = starboard.getList("messages", Document.class, StarboardManager.DEFAULT_CONFIGURATION);
        this.bot.getMongo().deleteStarById(event.getUserIdLong(), originalMessageId).thenCompose(result -> {
            if (result.getDeletedCount() == 0) {
                return CompletableFuture.completedFuture(null);
            }
            List<Bson> update = List.of(Operators.set("count", Operators.subtract("$count", 1)), Operators.set("messageId", Operators.cond(Operators.isEmpty(Operators.filter(config, Operators.gte(Operators.subtract("$count", 1), "$$this.stars"))), Operators.REMOVE, "$messageId")));
            FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER);
            return this.bot.getMongo().findAndUpdateStarboard(Filters.eq("originalMessageId", originalMessageId), update, options);
        }).whenComplete((updatedData, exception) -> {
            if (ExceptionUtility.sendErrorMessage(exception) || updatedData == null) {
                return;
            }
            if (!data.containsKey("messageId")) {
                return;
            }
            WebhookMessage webhookMessage = this.getStarboardMessage(starboard, updatedData, event.getGuild(), event.getMember(), emote, data.getBoolean("premium"));
            if (webhookMessage == null) {
                this.bot.getStarboardManager().deleteStarboard(data.getLong("messageId"), channel.getIdLong(), starboard.get("webhook", MongoDatabase.EMPTY_DOCUMENT));
            } else {
                this.bot.getStarboardManager().editStarboard(data.getLong("messageId"), channel.getIdLong(), starboard.get("webhook", MongoDatabase.EMPTY_DOCUMENT), webhookMessage);
            }
        });
    });
}
Also used : Document(org.bson.Document) net.dv8tion.jda.api.entities(net.dv8tion.jda.api.entities) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) JsonFormatter(com.sx4.bot.formatter.JsonFormatter) MongoWriteException(com.mongodb.MongoWriteException) MongoDatabase(com.sx4.bot.database.mongo.MongoDatabase) CompletableFuture(java.util.concurrent.CompletableFuture) ErrorResponse(net.dv8tion.jda.api.requests.ErrorResponse) GuildMessageReactionRemoveEvent(net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionRemoveEvent) Bson(org.bson.conversions.Bson) Formatter(com.sx4.bot.formatter.Formatter) WebhookEmbedBuilder(club.minnced.discord.webhook.send.WebhookEmbedBuilder) Sx4(com.sx4.bot.core.Sx4) WebhookEmbed(club.minnced.discord.webhook.send.WebhookEmbed) GenericEvent(net.dv8tion.jda.api.events.GenericEvent) com.mongodb.client.model(com.mongodb.client.model) EncodingUtil(net.dv8tion.jda.internal.utils.EncodingUtil) WebhookMessageBuilder(club.minnced.discord.webhook.send.WebhookMessageBuilder) Operators(com.sx4.bot.database.mongo.model.Operators) Attachment(net.dv8tion.jda.api.entities.Message.Attachment) ErrorResponseException(net.dv8tion.jda.api.exceptions.ErrorResponseException) MessageUtility(com.sx4.bot.utility.MessageUtility) StarboardManager(com.sx4.bot.managers.StarboardManager) CompletionException(java.util.concurrent.CompletionException) Route(net.dv8tion.jda.internal.requests.Route) RestActionImpl(net.dv8tion.jda.internal.requests.RestActionImpl) List(java.util.List) EventListener(net.dv8tion.jda.api.hooks.EventListener) GuildMessageReactionAddEvent(net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent) WebhookMessage(club.minnced.discord.webhook.send.WebhookMessage) ObjectId(org.bson.types.ObjectId) ExceptionUtility(com.sx4.bot.utility.ExceptionUtility) NotNull(org.jetbrains.annotations.NotNull) Comparator(java.util.Comparator) StringUtility(com.sx4.bot.utility.StringUtility) ErrorCategory(com.mongodb.ErrorCategory) Document(org.bson.Document) ReactionEmote(net.dv8tion.jda.api.entities.MessageReaction.ReactionEmote) Bson(org.bson.conversions.Bson) WebhookMessage(club.minnced.discord.webhook.send.WebhookMessage) List(java.util.List)

Aggregations

MongoDatabase (com.sx4.bot.database.mongo.MongoDatabase)4 Document (org.bson.Document)4 com.mongodb.client.model (com.mongodb.client.model)3 Sx4 (com.sx4.bot.core.Sx4)3 Operators (com.sx4.bot.database.mongo.model.Operators)3 ExceptionUtility (com.sx4.bot.utility.ExceptionUtility)3 List (java.util.List)3 CompletionException (java.util.concurrent.CompletionException)3 Permission (net.dv8tion.jda.api.Permission)3 User (net.dv8tion.jda.api.entities.User)3 Bson (org.bson.conversions.Bson)3 MongoWriteException (com.mongodb.MongoWriteException)2 Reason (com.sx4.bot.entities.mod.Reason)2 Clock (java.time.Clock)2 Duration (java.time.Duration)2 Guild (net.dv8tion.jda.api.entities.Guild)2 Member (net.dv8tion.jda.api.entities.Member)2 Role (net.dv8tion.jda.api.entities.Role)2 WebhookEmbed (club.minnced.discord.webhook.send.WebhookEmbed)1 WebhookEmbedBuilder (club.minnced.discord.webhook.send.WebhookEmbedBuilder)1