<commit_before>import logging

logger = logging.getLogger(__name__)


def start(token, client_id, google_api_key, loop):
    """Start the Discord client and log Modis into Discord."""
    import discord
    import asyncio

    # Create client
    logger.debug("Creating Discord client")
    asyncio.set_event_loop(loop)
    client = discord.Client()
    from . import _client
    _client.client = client

    # Save key info to data
    from .. import datatools
    if datatools.has_data():
        data = datatools.get_data()
    else:
        # Create a blank data file
        data = {"discord": {}}

    data["discord"]["token"] = token
    data["discord"]["client_id"] = client_id
    data["discord"]["google_api_key"] = google_api_key
    datatools.write_data(data)

    # Import event handlers
    logger.info("Importing event handlers")
    event_handlers = _get_event_handlers()

    # Create event handler combiner
    logger.debug("Compiling event handlers")

    def create_event_handler(event_handler_type):
        async def func(*args, **kwargs):
            for module_event_handler in event_handlers[event_handler_type]:
                module_event_handler_func = getattr(module_event_handler,
                                                    event_handler_type)
                await module_event_handler_func(*args, **kwargs)

        func.__name__ = event_handler_type
        return func

    # Register event handlers
    logger.debug("Registering event handlers into client")
    for event_handler in event_handlers.keys():
        client.event(create_event_handler(event_handler))<commit_msg>Initialise servers<commit_after>import logging

logger = logging.getLogger(__name__)


def start(token, client_id, google_api_key, loop):
    """Start the Discord client and log Modis into Discord."""
    import discord
    import asyncio

    # Create client
    logger.debug("Creating Discord client")
    asyncio.set_event_loop(loop)
    client = discord.Client()
    from . import _client
    _client.client = client

    # Save key info to data
    from .. import datatools
    if datatools.has_data():
        data = datatools.get_data()
    else:
        # Create a blank data file
        data = {"discord": {}}
        data["discord"]["servers"] = {}

    data["discord"]["token"] = token
    data["discord"]["client_id"] = client_id
    data["discord"]["google_api_key"] = google_api_key
    datatools.write_data(data)

    # Import event handlers
    logger.info("Importing event handlers")
    event_handlers = _get_event_handlers()

    # Create event handler combiner
    logger.debug("Compiling event handlers")

    def create_event_handler(event_handler_type):
        async def func(*args, **kwargs):
            for module_event_handler in event_handlers[event_handler_type]:
                module_event_handler_func = getattr(module_event_handler,
                                                    event_handler_type)
                await module_event_handler_func(*args, **kwargs)

        func.__name__ = event_handler_type
        return func

    # Register event handlers
    logger.debug("Registering event handlers into client")
    for event_handler in event_handlers.keys():
        client.event(create_event_handler(event_handler))
{'fraction_non_alphanumeric': 0.0898021308980213, 'fraction_numerical': 0.0, 'mean_word_length': 2.9072532699167657, 'pattern_counts': {'":': 2, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3598049', 'n_tokens_mistral': 930, 'n_tokens_neox': 908, 'n_words': 221}