<commit_before>import discord
from discord.ext import commands
from .utils.auth import check_auths, R_ADMIN, R_DEV
from subsystems.borealis_exceptions import ApiError

class MonitorCog:
    def __init__(self, bot):
        self.bot = bot

    @staticmethod
    def valid_command(command):
        command = str(command)

        if not command:
            raise commands.errors.BadArgument("No command sent.")

        command = command.lower()

        if command not in ["start", "stop", "restart"]:
            raise commands.errors.BadArgument("{} is not a valid command for the monitor."
                                     .format(command))

        return command

    @commands.command(aliases=["monitorcontrol", "mcontrol", "monitor"])
    @check_auths([R_ADMIN, R_DEV])
    async def monitor_control(self, ctx, server: str, command: valid_command):
        api = ctx.bot.Api()
        conf = ctx.bot.Config()
        try:
            data = await api.query_monitor({
                "cmd": "server_control",
                "args": {"control": command, "server": server.lower()},
                "auths": conf.get_user_auths(str(ctx.author.id))
            })
<commit_msg>Fix monitor cog's command verification<commit_after>import discord
from discord.ext import commands
from .utils.auth import check_auths, R_ADMIN, R_DEV
from subsystems.borealis_exceptions import ApiError

def valid_command(command):
    command = str(command)

    if not command:
        raise commands.errors.BadArgument("No command sent.")

    command = command.lower()

    if command not in ["start", "stop", "restart"]:
        raise commands.errors.BadArgument("{} is not a valid command for the monitor."
                                    .format(command))

    return command

class MonitorCog:
    def __init__(self, bot):
        self.bot = bot

    @commands.command(aliases=["monitorcontrol", "mcontrol", "monitor"])
    @check_auths([R_ADMIN, R_DEV])
    async def monitor_control(self, ctx, server: str, command: valid_command):
        api = ctx.bot.Api()
        conf = ctx.bot.Config()
        try:
            data = await api.query_monitor({
                "cmd": "server_control",
                "args": {"control": command, "server": server.lower()},
                "auths": conf.get_user_auths(str(ctx.author.id))
            })

{'fraction_non_alphanumeric': 0.1161400512382579, 'fraction_numerical': 0.0, 'mean_word_length': 2.4814264487369986, 'pattern_counts': {'":': 10, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1016072', 'n_tokens_mistral': 676, 'n_tokens_neox': 651, 'n_words': 177}