<commit_before>package com.nincraft.ninbot.components.owner;

import com.nincraft.ninbot.components.command.AbstractCommand;
import com.nincraft.ninbot.components.common.MessageUtils;
import com.nincraft.ninbot.components.common.RolePermission;
import com.nincraft.ninbot.components.config.ConfigConstants;
import com.nincraft.ninbot.components.config.ConfigService;
import lombok.val;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class OwnerCommand extends AbstractCommand {

    private ConfigService configService;

    public OwnerCommand(ConfigService configService) {
        length = 3;
        name = "owner";
        description = "Owner commands";
        permissionLevel = RolePermission.OWNER;
        hidden = true;
        this.configService = configService;
    }

    @Override
    protected void executeCommand(MessageReceivedEvent event) {
        switch (getSubcommand(event.getMessage().getContentStripped())) {
            case "restart":
                restart(event.getMessage());
                break;
            case "logs":
                showLogs(event);
                break;
            default:
                break;
        }
    }

    private void restart(Message message) {
        MessageUtils.reactSuccessfulResponse(message);
        System.exit(0);
    }

    private void showLogs(MessageReceivedEvent event) {
        val announceChannelId = configService.getSingleValueByName(event.getGuild().getId(), ConfigConstants.ERROR_ANNOUNCE_CHANNEL);
        if (announceChannelId.isPresent()) {
            val announceChannel = event.getJDA().getTextChannelById(announceChannelId.get());
            announceChannel.sendFile(new File("ninbot.log")).queue();
        }
    }
}<commit_msg>Refactor<commit_after>package com.nincraft.ninbot.components.owner;

import com.nincraft.ninbot.components.command.AbstractCommand;
import com.nincraft.ninbot.components.common.RolePermission;
import com.nincraft.ninbot.components.config.ConfigConstants;
import com.nincraft.ninbot.components.config.ConfigService;
import lombok.val;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class OwnerCommand extends AbstractCommand {

    private ConfigService configService;

    public OwnerCommand(ConfigService configService) {
        length = 3;
        name = "owner";
        description = "Owner commands";
        permissionLevel = RolePermission.OWNER;
        hidden = true;
        this.configService = configService;
    }

    @Override
    protected void executeCommand(MessageReceivedEvent event) {
        switch (getSubcommand(event.getMessage().getContentStripped())) {
            case "restart":
                restart(event.getMessage());
                break;
            case "logs":
                showLogs(event);
                break;
            default:
                break;
        }
    }

    private void restart(Message message) {
        messageUtils.reactSuccessfulResponse(message);
        System.exit(0);
    }

    private void showLogs(MessageReceivedEvent event) {
        val announceChannelId = configService.getSingleValueByName(event.getGuild().getId(), ConfigConstants.ERROR_ANNOUNCE_CHANNEL);
        if (announceChannelId.isPresent()) {
            val announceChannel = event.getJDA().getTextChannelById(announceChannelId.get());
            announceChannel.sendFile(new File("ninbot.log")).queue();
        }
    }
}
{'fraction_non_alphanumeric': 0.09611231101511879, 'fraction_numerical': 0.0021598272138228943, 'mean_word_length': 3.0359477124183005, 'pattern_counts': {'":': 4, '<': 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': '4670775', 'n_tokens_mistral': 1021, 'n_tokens_neox': 999, 'n_words': 168}