<commit_before>package de.panzercraft.bot.supreme.permission;

import de.panzercraft.bot.supreme.entities.MessageEvent;
import de.panzercraft.bot.supreme.util.Standard;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.PermissionOverride;
import net.dv8tion.jda.core.entities.Role;

/**
 * PermissionHandler
 *
 * @author Panzer1119
 */
public class PermissionHandler {

    public static final boolean check(PermissionRoleFilter filter, MessageEvent event, boolean withMessage) {
        if (filter == null) {
            return true;
        }
        if (event == null) {
            return false;
        }
        if (!event.isPrivate()) {
            for (Role role : event.getGuild().getMember(event.getAuthor()).getRoles()) {
                final PermissionRole temp = PermissionRole.getPermissionRoleByGuildIdAndRoleId(event.getGuild().getId(), role.getId());
                if (temp != null && filter.isPermissionGranted(temp, event.getMember())) {
                    return true;
                }
            }
        } else {
            return Standard.isSuperOwner(event.getAuthor());
        }
        if (withMessage) {
            sendNoPermissionMessage(event);
        }
        return false;
    }
    <commit_msg>Hotfix for private messages and no permissions answers<commit_after>package de.panzercraft.bot.supreme.permission;

import de.panzercraft.bot.supreme.entities.MessageEvent;
import de.panzercraft.bot.supreme.util.Standard;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.PermissionOverride;
import net.dv8tion.jda.core.entities.Role;

/**
 * PermissionHandler
 *
 * @author Panzer1119
 */
public class PermissionHandler {

    public static final boolean check(PermissionRoleFilter filter, MessageEvent event, boolean withMessage) {
        if (filter == null) {
            return true;
        }
        if (event == null) {
            return false;
        }
        if (!event.isPrivate()) {
            for (Role role : event.getGuild().getMember(event.getAuthor()).getRoles()) {
                final PermissionRole temp = PermissionRole.getPermissionRoleByGuildIdAndRoleId(event.getGuild().getId(), role.getId());
                if (temp != null && filter.isPermissionGranted(temp, event.getMember())) {
                    return true;
                }
            }
        } else {
            if (Standard.isSuperOwner(event.getAuthor())) {
                return true;
            }
        }
        if (withMessage) {
            sendNoPermissionMessage(event);
        }
        return false;
    }
    
{'fraction_non_alphanumeric': 0.11051693404634581, 'fraction_numerical': 0.006417112299465241, 'mean_word_length': 2.430317848410758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2768794', 'n_tokens_mistral': 816, 'n_tokens_neox': 802, 'n_words': 145}