#!/usr/bin/env python
import asyncio
import logging
import sys

import discord
from discord.ext.commands import when_mentioned_or
import yaml

from bot import BeattieBot

try:
    import uvloop
except ImportError:
    pass
else:
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

with open('config.yaml') as file:
    config = yaml.load(file)

self_bot = 'self' in sys.argv

if self_bot:
    token = config['self']
    bot = BeattieBot('b>', self_bot=True)
else:
    token = config['token']
    bot = BeattieBot(when_mentioned_or('>'))

for extension in ('default', 'rpg', 'eddb', 'repl', 'wolfram', 'nsfw'):
    try:
        bot.load_extension(extension)
    except Exception as e:
        print(f'Failed to load extension {extension}\n{type(e).__name__}: {e}')

if not self_bot:
    logger = logging.getLogger('discord')
    logger.setLevel(logging.INFO)
    handler = logging.FileHandler(
        filename='discord.log', encoding='utf-8', mode='w')
    handler.setFormatter(
        logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
    logger.addHandler(handler)
    bot.logger = logger

bot.run(token, bot=not self_bot)

#!/usr/bin/env python
import asyncio
import logging
import sys

import discord
from discord.ext.commands import when_mentioned_or
import yaml

from bot import BeattieBot

try:
    import uvloop
except ImportError:
    pass
else:
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

with open('config.yaml') as file:
    config = yaml.load(file)

self_bot = 'self' in sys.argv

if self_bot:
    token = config['self']
    bot = BeattieBot('b>', self_bot=True)
else:
    token = config['token']
    bot = BeattieBot(when_mentioned_or('>'))

for extension in ('default', 'rpg', 'eddb', 'repl', 'wolfram', 'stats'):
    try:
        bot.load_extension(extension)
    except Exception as e:
        print(f'Failed to load extension {extension}\n{type(e).__name__}: {e}')

if not self_bot:
    logger = logging.getLogger('discord')
    logger.setLevel(logging.INFO)
    handler = logging.FileHandler(
        filename='discord.log', encoding='utf-8', mode='w')
    handler.setFormatter(
        logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
    logger.addHandler(handler)
    bot.logger = logger

bot.run(token, bot=not self_bot)

Load stats on startup, don't load nsfw
Load stats on startup, don't load nsfw
