<commit_before>package stream.flarebot.flarebot;

import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.audit.ActionType;
import net.dv8tion.jda.core.audit.AuditLogChange;
import net.dv8tion.jda.core.audit.AuditLogEntry;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.channel.text.TextChannelCreateEvent;
import net.dv8tion.jda.core.events.channel.text.TextChannelDeleteEvent;
import net.dv8tion.jda.core.events.channel.voice.VoiceChannelCreateEvent;
import net.dv8tion.jda.core.events.channel.voice.VoiceChannelDeleteEvent;
import net.dv8tion.jda.core.events.guild.GuildBanEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberLeaveEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberNickChangeEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleAddEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleRemoveEvent;
import net.dv8tion.jda.core.events.guild.update.GenericGuildUpdateEvent;
import net.dv8tion.jda.core.events.guild.update.GuildUpdateExplicitContentLevelEvent;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceJoinEvent;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent;
import net.dv8tion.jda.core.events.message.MessageDeleteEvent;
import net.dv8tion.jda.core.events.message.MessageUpdateEvent;
import net.dv8tion.jda.core.events.role.RoleCreateEvent;
import net.dv8tion.jda.core.events.role.RoleDeleteEvent;
import net.dv8tion.jda.core.events.role.update.GenericRoleUpdateEvent;
import net.dv8tion.jda.core.events.role.update.RoleUpdatePositionEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import stream.flarebot.flarebot.database.RedisController;
import stream.flarebot.flarebot.database.RedisMessage;
import stream.flarebot.flarebot.mod.modlog.ModlogEvent;
import stream.flarebot.flarebot.mod.modlog.ModlogHandler;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.util.GeneralUtils;
import stream.flarebot.flarebot.util.MessageUtils;

import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ModlogEvents extends ListenerAdapter {

    private long roleResponseNumber = 0;
    private long guildResponseNumber = 0;

    @Override
    public void onGuildBan(GuildBanEvent event) {
        if (cannotHandle(event.getGuild(), ModlogEvent.USER_BANNED)) return;
        event.getGuild().getAuditLogs().limit(1).type(ActionType.BAN).queue(auditLogEntries -> {
            AuditLogEntry entry = auditLogEntries.get(0);
            boolean validEntry = true;
            validEntry = entry.getTargetId().equals(event.getUser().getId());
            ModlogHandler.getInstance().postToModlog(getGuild(event.getGuild()), ModlogEvent.USER_BANNED, event.getUser(),
                    validEntry ? entry.getUser() : null,
                    validEntry ? entry.getReason() : null);
        });
    }

    @Override
    public void onGuildMemberJoin(GuildMemberJoinEvent event) {
        if (cannotHandle(event.getGuild(), ModlogEvent.MEMBER_JOIN)) return;
        ModlogHandler.getInstance().postToModlog(getGuild(event.getGuild()), ModlogEvent.MEMBER_JOIN, event.getUser());
    }

    @Override
    public void onGuildMemberLeave(GuildMemberLeaveEvent event) {
        if (cannotHandle(event.getGuild(), ModlogEvent.MEMBER_LEAVE)) return;
        event.getGuild().getAuditLogs().limit(1).type(ActionType.KICK).queue(auditLogEntries -> {
            AuditLogEntry entry = auditLogEntries.get(0);
            // If the user kicked wasn't this person then ignore it
            if (!entry.getTargetId().equals(event.getUser().getId())) return;
            User responsible = null;
            String reason = null;
            if (entry.getType() == ActionType.KICK) {
                responsible = entry.getUser();
                reason = entry.getReason();
            }
            ModlogHandler.getInstance().postToModlog(getGuild(event.getGuild()), responsible != null ?
                            ModlogEvent.USER_KICKED : ModlogEvent.MEMBER_LEAVE, event.getUser(),<commit_msg>Wtffff<commit_after>package stream.flarebot.flarebot;

import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.audit.ActionType;
import net.dv8tion.jda.core.audit.AuditLogChange;
import net.dv8tion.jda.core.audit.AuditLogEntry;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.channel.text.TextChannelCreateEvent;
import net.dv8tion.jda.core.events.channel.text.TextChannelDeleteEvent;
import net.dv8tion.jda.core.events.channel.voice.VoiceChannelCreateEvent;
import net.dv8tion.jda.core.events.channel.voice.VoiceChannelDeleteEvent;
import net.dv8tion.jda.core.events.guild.GuildBanEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberLeaveEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberNickChangeEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleAddEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleRemoveEvent;
import net.dv8tion.jda.core.events.guild.update.GenericGuildUpdateEvent;
import net.dv8tion.jda.core.events.guild.update.GuildUpdateExplicitContentLevelEvent;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceJoinEvent;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent;
import net.dv8tion.jda.core.events.message.MessageDeleteEvent;
import net.dv8tion.jda.core.events.message.MessageUpdateEvent;
import net.dv8tion.jda.core.events.role.RoleCreateEvent;
import net.dv8tion.jda.core.events.role.RoleDeleteEvent;
import net.dv8tion.jda.core.events.role.update.GenericRoleUpdateEvent;
import net.dv8tion.jda.core.events.role.update.RoleUpdatePositionEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import stream.flarebot.flarebot.database.RedisController;
import stream.flarebot.flarebot.database.RedisMessage;
import stream.flarebot.flarebot.mod.modlog.ModlogEvent;
import stream.flarebot.flarebot.mod.modlog.ModlogHandler;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.util.GeneralUtils;
import stream.flarebot.flarebot.util.MessageUtils;

import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ModlogEvents extends ListenerAdapter {

    private long roleResponseNumber = 0;
    private long guildResponseNumber = 0;

    @Override
    public void onGuildBan(GuildBanEvent event) {
        if (cannotHandle(event.getGuild(), ModlogEvent.USER_BANNED)) return;
        event.getGuild().getAuditLogs().limit(1).type(ActionType.BAN).queue(auditLogEntries -> {
            AuditLogEntry entry = auditLogEntries.get(0);
            boolean validEntry = entry.getTargetId().equals(event.getUser().getId());
            ModlogHandler.getInstance().postToModlog(getGuild(event.getGuild()), ModlogEvent.USER_BANNED, event.getUser(),
                    validEntry ? entry.getUser() : null,
                    validEntry ? entry.getReason() : null);
        });
    }

    @Override
    public void onGuildMemberJoin(GuildMemberJoinEvent event) {
        if (cannotHandle(event.getGuild(), ModlogEvent.MEMBER_JOIN)) return;
        ModlogHandler.getInstance().postToModlog(getGuild(event.getGuild()), ModlogEvent.MEMBER_JOIN, event.getUser());
    }

    @Override
    public void onGuildMemberLeave(GuildMemberLeaveEvent event) {
        if (cannotHandle(event.getGuild(), ModlogEvent.MEMBER_LEAVE)) return;
        event.getGuild().getAuditLogs().limit(1).type(ActionType.KICK).queue(auditLogEntries -> {
            AuditLogEntry entry = auditLogEntries.get(0);
            // If the user kicked wasn't this person then ignore it
            if (!entry.getTargetId().equals(event.getUser().getId())) return;
            User responsible = null;
            String reason = null;
            if (entry.getType() == ActionType.KICK) {
                responsible = entry.getUser();
                reason = entry.getReason();
            }
            ModlogHandler.getInstance().postToModlog(getGuild(event.getGuild()), responsible != null ?
                            ModlogEvent.USER_KICKED : ModlogEvent.MEMBER_LEAVE, event.getUser(),
{'fraction_non_alphanumeric': 0.11336755188573978, 'fraction_numerical': 0.008257085471992859, 'mean_word_length': 4.297281323877068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6885898', 'n_tokens_mistral': 3016, 'n_tokens_neox': 2879, 'n_words': 371}