<commit_before>package stream.flarebot.flarebot.commands.moderation.mod;

import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
import org.apache.commons.lang3.text.WordUtils;
import stream.flarebot.flarebot.commands.Command;
import stream.flarebot.flarebot.commands.CommandType;
import stream.flarebot.flarebot.mod.Moderation;
import stream.flarebot.flarebot.mod.modlog.ModlogAction;
import stream.flarebot.flarebot.mod.modlog.ModlogEvent;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.util.GeneralUtils;
import stream.flarebot.flarebot.util.MessageUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class ModlogCommand implements Command {

    @Override
    public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
        if (args.length >= 1) {
            if (args[0].equalsIgnoreCase("list")) {
                int page = 1;
                if (args.length == 2) {
                    page = GeneralUtils.getInt(args[1], 1);
                }
                int pageSize = 15;
                Set<ModlogAction> actions = guild.getModeration().getEnabledActions();
                int pages = actions.size() < pageSize ? 1 : (actions.size() / pageSize)
                        + (actions.size() % pageSize != 0 ? 1 : 0);

                int start;
                int end;

                start = pageSize * (page - 1);
                end = Math.min(start + pageSize, actions.size());

                if (page > pages || page < 0) {
                    MessageUtils.sendErrorMessage("That page doesn't exist. Current page count: " + pages, channel);
                    return;
                } else {
                    List<ModlogAction> events = new ArrayList<>(actions).subList(start, end);

                    if (events.isEmpty()) {
                        MessageUtils.sendErrorMessage("No Events are enabled", channel);
                        return;
                    }
                    List<String> header = new ArrayList<>();
                    header.add("Event");
                    header.add("Compact");
                    header.add("Channel");

                    List<List<String>> body = new ArrayList<>();
                    for (ModlogAction modlogAction : events) {
                        if (guild.getModeration().isEventEnabled(guild, modlogAction.getEvent())) {
                            List<String> part = new ArrayList<>();
                            part.add(modlogAction.getEvent().getName());
                            part.add(String.valueOf(modlogAction.isCompacted()));
                            part.add(modlogAction.getModlogChannel(guild.getGuild()).getName());
                            body.add(part);
                        }
                    }

                    channel.sendMessage(MessageUtils.makeAsciiTable(header, body, " Page " + page + "/" + pages)).queue();
                    return;
                }
            }
            if (args[0].equalsIgnoreCase("features")) {
                int page = 1;
                if (args.length == 2) {
                    page = GeneralUtils.getInt(args[1], 1);
                }
                
                listEvents(channel, page, guild, false);
                return;
            }
        }
        if (args.length >= 2) {
            String eventArgument = MessageUtils.getMessage(args, 1, Math.max(2, args.length - 1));
            ModlogEvent event = ModlogEvent.getEvent(eventArgument);
            boolean all = false;
            boolean defaultEvents = false;
            if (event == null) {
                if (eventArgument.equalsIgnoreCase("all"))
                    all = true;
                else if (eventArgument.equalsIgnoreCase("default"))
                    defaultEvents = true;
                else {
                    EmbedBuilder errorBuilder = new EmbedBuilder();
                    errorBuilder.setDescription("Invalid Event: `" + eventArgument + "`\n"
                                    + "For a list of all events do `{%}modlog features`, "
                                    + "for a list of all enabled events do `{%}modlog list`.");
                    MessageUtils.sendErrorMessage(errorBuilder, channel);
                    return;
                }
            }
            Moderation moderation = guild.getModeration();
            if (args[0].equalsIgnoreCase("enable")) {
                TextChannel tc = GeneralUtils.getChannel(args[args.length - 1], guild);
                if (tc == null) {
                    MessageUtils.sendErrorMessage("I cannot find the channel `" + args[args.length - 1] + "` try to mention the channel " +<commit_msg>Should fix incorrect event for disable<commit_after>package stream.flarebot.flarebot.commands.moderation.mod;

import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
import org.apache.commons.lang3.text.WordUtils;
import stream.flarebot.flarebot.commands.Command;
import stream.flarebot.flarebot.commands.CommandType;
import stream.flarebot.flarebot.mod.Moderation;
import stream.flarebot.flarebot.mod.modlog.ModlogAction;
import stream.flarebot.flarebot.mod.modlog.ModlogEvent;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.util.GeneralUtils;
import stream.flarebot.flarebot.util.MessageUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class ModlogCommand implements Command {

    @Override
    public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
        if (args.length >= 1) {
            if (args[0].equalsIgnoreCase("list")) {
                int page = 1;
                if (args.length == 2) {
                    page = GeneralUtils.getInt(args[1], 1);
                }
                int pageSize = 15;
                Set<ModlogAction> actions = guild.getModeration().getEnabledActions();
                int pages = actions.size() < pageSize ? 1 : (actions.size() / pageSize)
                        + (actions.size() % pageSize != 0 ? 1 : 0);

                int start;
                int end;

                start = pageSize * (page - 1);
                end = Math.min(start + pageSize, actions.size());

                if (page > pages || page < 0) {
                    MessageUtils.sendErrorMessage("That page doesn't exist. Current page count: " + pages, channel);
                    return;
                } else {
                    List<ModlogAction> events = new ArrayList<>(actions).subList(start, end);

                    if (events.isEmpty()) {
                        MessageUtils.sendErrorMessage("No Events are enabled", channel);
                        return;
                    }
                    List<String> header = new ArrayList<>();
                    header.add("Event");
                    header.add("Compact");
                    header.add("Channel");

                    List<List<String>> body = new ArrayList<>();
                    for (ModlogAction modlogAction : events) {
                        if (guild.getModeration().isEventEnabled(guild, modlogAction.getEvent())) {
                            List<String> part = new ArrayList<>();
                            part.add(modlogAction.getEvent().getName());
                            part.add(String.valueOf(modlogAction.isCompacted()));
                            part.add(modlogAction.getModlogChannel(guild.getGuild()).getName());
                            body.add(part);
                        }
                    }

                    channel.sendMessage(MessageUtils.makeAsciiTable(header, body, " Page " + page + "/" + pages)).queue();
                    return;
                }
            }
            if (args[0].equalsIgnoreCase("features")) {
                int page = 1;
                if (args.length == 2) {
                    page = GeneralUtils.getInt(args[1], 1);
                }
                
                listEvents(channel, page, guild, false);
                return;
            }
        }
        if (args.length >= 2) {
            String eventArgument = MessageUtils.getMessage(args, 1, 
                            args[0].equalsIgnoreCase("enable") ? Math.max(2, args.length - 1) : args.length);
            ModlogEvent event = ModlogEvent.getEvent(eventArgument);
            boolean all = false;
            boolean defaultEvents = false;
            if (event == null) {
                if (eventArgument.equalsIgnoreCase("all"))
                    all = true;
                else if (eventArgument.equalsIgnoreCase("default"))
                    defaultEvents = true;
                else {
                    EmbedBuilder errorBuilder = new EmbedBuilder();
                    errorBuilder.setDescription("Invalid Event: `" + eventArgument + "`\n"
                                    + "For a list of all events do `{%}modlog features`, "
                                    + "for a list of all enabled events do `{%}modlog list`.");
                    MessageUtils.sendErrorMessage(errorBuilder, channel);
                    return;
                }
            }
            Moderation moderation = guild.getModeration();
            if (args[0].equalsIgnoreCase("enable")) {
                TextChannel tc = GeneralUtils.getChannel(args[args.length - 1], guild);
                if (tc == null) {
                    MessageUtils.sendErrorMessage("I cannot find the channel `" + args[args.length - 1] + "` try to mention the channel " +
{'fraction_non_alphanumeric': 0.10985616372236702, 'fraction_numerical': 0.006467805772757988, 'mean_word_length': 1.6958105646630237, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1377059', 'n_tokens_mistral': 2798, 'n_tokens_neox': 2564, 'n_words': 561}