<commit_before>from jsonschema import validate
from json import load
import logging
import discord
from config_schema import config_schema
from manager.monitor_discord import DiscordBot
from manager.monitor_games import MonitorGames
from manager.objects.game import Game


class Config:
    def __init__(self, config_file="config.json"):
        self._configure_logger()
        with open(config_file) as data_file:
            data = load(data_file)
        data_file.close()
        validate(data, config_schema)
        self.discord_user = data['discord']['username']
        self.discord_token = data['discord']['oauth_token']
        self.channels = data['discord']['channels']
        self.admins = {
            'global': data['discord']['global_admins'],
        }
        self.games = {}
        for attrs in data['games']:
            self.admins[attrs['name']] = attrs['admins']
            if attrs['name'] not in self.games:
                self.games[attrs['name']] = Game(attrs)
        self.required_roles = data['discord']['required_roles']
        monitor = MonitorGames(self.logger, self.games)
        self.discord_client = discord.Client()
        bot = DiscordBot(self.logger, self.channels, self.admins, self.required_roles, self.games)
        bot.register_events(self.discord_client)
        self.discord_client.run(self.discord_token, loop=monitor.loop)

    def _configure_logger(self):
        """
        Creates and configures a logger to log to "game_manager.log"
        :return:
        """<commit_msg>fix(discord): correct discord bot invocation<commit_after>from jsonschema import validate
from json import load
import logging
import discord
from config_schema import config_schema
from manager.monitor_discord import DiscordBot
from manager.monitor_games import MonitorGames
from manager.objects.game import Game


class Config:
    def __init__(self, config_file="config.json"):
        self._configure_logger()
        with open(config_file) as data_file:
            data = load(data_file)
        data_file.close()
        validate(data, config_schema)
        self.discord_user = data['discord']['username']
        self.discord_token = data['discord']['oauth_token']
        self.channels = data['discord']['channels']
        self.admins = {
            'global': data['discord']['global_admins'],
        }
        self.games = {}
        for attrs in data['games']:
            self.admins[attrs['name']] = attrs['admins']
            if attrs['name'] not in self.games:
                self.games[attrs['name']] = Game(attrs)
        self.required_roles = data['discord']['required_roles']
        monitor = MonitorGames(self.logger, self.games)
        self.discord_client = discord.Client(loop=monitor.loop)
        bot = DiscordBot(self.logger, self.channels, self.admins, self.required_roles, self.games)
        bot.register_events(self.discord_client)
        self.discord_client.run(self.discord_token)

    def _configure_logger(self):
        """
        Creates and configures a logger to log to "game_manager.log"
        :return:
        """
{'fraction_non_alphanumeric': 0.1122942884801549, 'fraction_numerical': 0.0, 'mean_word_length': 3.005167958656331, 'pattern_counts': {'":': 0, '<': 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': '4761377', 'n_tokens_mistral': 911, 'n_tokens_neox': 886, 'n_words': 191}