<commit_before>from .utils import load_db, save_db, getname
import discord
import asyncio
import time


class CoreBot(discord.Client):
    commands = {} # !cmd -> function wrapper. Functions take (self, message, content)
    users = {} # id/fullname -> {id, fullname, mention, name}
    tasks = [] # [interval(s), function] functions take (self)
    special = [] # [callable, function] callable takes (self, message) and returns True if function should be run. Func takes (self, message, content)

    def add_command(self, *cmds):
        if not len(cmds):
            raise ValueError("Must provide at least one command")
        def wrapper(func):
            for cmd in cmds:
                self.commands[cmd] = func
            return func
        return wrapper

    def add_task(self, interval):
        def wrapper(func):
            self.tasks.append((interval, func))
            return func
        return wrapper

    def add_special(self, check):
        def wrapper(func):
            self.special.append((check, func))
            return func
        return wrapper

    def EnableAll(self, *bots):
        for bot in bots:
            if callable(bot):
                self = bot(self)
            else:
                raise TypeError("Bot is not callable")
        return self

    async def on_ready(self):
        self.users = load_db('users.json')
        self._general = discord.utils.get(
            self.get_all_channels(),
            name='general',
            type=discord.ChannelType.text
        )
        self.general = self._general
        self._bug_channel = self._general #Change which channels these use
        self.bug_channel = self._general #Change which channels these use
        self.dev_channel = self._general #Change which channels these use
        self.update_times = [0] * len(self.tasks) # set all tasks to update at next trigger

    async def close(self):
        save_db(self.users, 'users.json')
        await super().close()

    async def on_message(self, message):
        if message.author == self.user:
            return
        struct = {
            'id': message.author.id,
            'fullname': str(message.author),
            'mention': message.author.mention,
            'name': getname(message.author)
        }
        self.users[str(message.author)] = struct<commit_msg>Added command debug<commit_after>from .utils import load_db, save_db, getname
import discord
import asyncio
import time


class CoreBot(discord.Client):
    commands = {} # !cmd -> function wrapper. Functions take (self, message, content)
    users = {} # id/fullname -> {id, fullname, mention, name}
    tasks = [] # [interval(s), function] functions take (self)
    special = [] # [callable, function] callable takes (self, message) and returns True if function should be run. Func takes (self, message, content)

    def add_command(self, *cmds):
        if not len(cmds):
            raise ValueError("Must provide at least one command")
        def wrapper(func):
            for cmd in cmds:
                self.commands[cmd] = func
            return func
        return wrapper

    def add_task(self, interval):
        def wrapper(func):
            self.tasks.append((interval, func))
            return func
        return wrapper

    def add_special(self, check):
        def wrapper(func):
            self.special.append((check, func))
            return func
        return wrapper

    def EnableAll(self, *bots):
        for bot in bots:
            if callable(bot):
                self = bot(self)
            else:
                raise TypeError("Bot is not callable")
        return self

    async def on_ready(self):
        print("Commands:", self.commands)
        self.users = load_db('users.json')
        self._general = discord.utils.get(
            self.get_all_channels(),
            name='general',
            type=discord.ChannelType.text
        )
        self.general = self._general
        self._bug_channel = self._general #Change which channels these use
        self.bug_channel = self._general #Change which channels these use
        self.dev_channel = self._general #Change which channels these use
        self.update_times = [0] * len(self.tasks) # set all tasks to update at next trigger

    async def close(self):
        save_db(self.users, 'users.json')
        await super().close()

    async def on_message(self, message):
        if message.author == self.user:
            return
        struct = {
            'id': message.author.id,
            'fullname': str(message.author),
            'mention': message.author.mention,
            'name': getname(message.author)
        }
        self.users[str(message.author)] = struct
{'fraction_non_alphanumeric': 0.10067539046010975, 'fraction_numerical': 0.00042211903756859433, 'mean_word_length': 2.117763157894737, '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': '595112', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1255, 'n_words': 385}