<commit_before>'''Admin commands'''
import modules.commands as commands
import json
import discord
import re
import asyncio

with open("database/adminweenie.json","r") as infile:
    admin = json.loads(infile.read())

with open("database/warn.json","r") as infile:
    warnings = json.loads(infile.read())    
    
'''Clear/Removes a given amount of messages.'''
async def clear_logic(message, client):
    if message.author.permissions_in(message.channel).manage_messages:
        try:
            amount = message.content.split(' ')
            amount_number = amount[1]
            amount = int(amount_number) + 1
            print(message.author.name + ' cleared {} messages'.format(amount))
            deleted = await client.purge_from(message.channel, limit=int(amount), check=None)
            await asyncio.sleep(1)
            tbd = await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
            await asyncio.sleep(8)
            await client.delete_message(tbd)
        except ValueError:
            await client.send_message(message.channel, 'Error, Did you specify number?')
    else:
        await client.send_message(message.channel, 'You need manage messages permission on this server, to use this commands')
commands.add_command(command_name='clear', command_function=clear_logic)

async def warning_add(message, client):
    if message.author.permissions_in(message.channel).ban_members:
        person = re.sub('[!@<>]', '', message.content)
        person = person.replace('warn ', '')
        r_person = person.split()[0]
        print(person)
        if r_person not in warnings:
            warnings[r_person] = []
        warnings[r_person].append(person.split(person)[1])
        if len(warnings[r_person]) > 3:
            if len(warnings[r_person]) > 2:
                await client.send_message(message.server.get_member(r_person), person.split()[1:])
            else:
                await client.send_message(message.server.get_member(r_person), person.split()[1:])
                await client.send_message(message.channel, 'The next warning this person gets will result in a ban!')
        else:
            await client.send_message(message.server.get_member(person), person.split()[1:])
            await client.send_message(message.channel, 'Banning is not added yet! D:')
    else:
        await client.send_message(message.channel, '`ban_members` permission is needed for this command!')
commands.add_command(command_name='warn', command_function=warning_add)

async def warning_amount(message, client):<commit_msg>Update admin.py<commit_after>'''Admin commands'''
import modules.commands as commands
import json
import discord
import re
import asyncio

with open("database/adminweenie.json","r") as infile:
    admin = json.loads(infile.read())

with open("database/warn.json","r") as infile:
    warnings = json.loads(infile.read())    
    
'''Clear/Removes a given amount of messages.'''
async def clear_logic(message, client):
    if message.author.permissions_in(message.channel).manage_messages:
        try:
            amount = message.content.split(' ')
            amount_number = amount[1]
            amount = int(amount_number) + 1
            print(message.author.name + ' cleared {} messages'.format(amount))
            deleted = await client.purge_from(message.channel, limit=int(amount), check=None)
            await asyncio.sleep(1)
            tbd = await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
            await asyncio.sleep(8)
            await client.delete_message(tbd)
        except ValueError:
            await client.send_message(message.channel, 'Error, Did you specify number?')
    else:
        await client.send_message(message.channel, 'You need manage messages permission on this server, to use this commands')
commands.add_command(command_name='clear', command_function=clear_logic)

async def warning_add(message, client):
    if message.author.permissions_in(message.channel).ban_members:
        person = re.sub('[!@<>]', '', message.content)
        person = person.replace('warn ', '')
        r_person = person.split()[0]
        print(person)
        if r_person not in warnings:
            warnings[r_person] = []
        warnings[r_person].append(person.split(person)[1])
        if len(warnings[r_person]) > 3:
            if len(warnings[r_person]) > 2:
                await client.send_message(message.server.get_member(r_person), person.split()[1:])
            else:
                await client.send_message(message.server.get_member(r_person), person.split()[1:])
                await client.send_message(message.channel, 'The next warning this person gets will result in a ban!')
        elif len(warnings[r_person]) >= 3:
            await client.send_message(message.server.get_member(r_person), person.split()[1:])
            await client.send_message(message.channel, 'Banning is not added yet! D:')
    else:
        await client.send_message(message.channel, '`ban_members` permission is needed for this command!')
commands.add_command(command_name='warn', command_function=warning_add)

async def warning_amount(message, client):
{'fraction_non_alphanumeric': 0.12052117263843648, 'fraction_numerical': 0.004406974516190841, 'mean_word_length': 3.250814332247557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '459154', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1492, 'n_words': 334}