34 lines
995 B
Python
34 lines
995 B
Python
#!/usr/bin/env python3
|
|
import json
|
|
from discord.ext import commands
|
|
import logging
|
|
import os
|
|
|
|
|
|
KRUHOBOT_FOLDER = os.environ.get("KRUHOBOT_FOLDER", '/')
|
|
|
|
|
|
logger = logging.getLogger('kruhobot')
|
|
logger.setLevel(logging.INFO)
|
|
handler = logging.FileHandler(filename=os.path.join(KRUHOBOT_FOLDER, 'kruhobot.log'), encoding='utf-8', mode='w')
|
|
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
|
|
logger.addHandler(handler)
|
|
|
|
logger.info("Loading config")
|
|
with open(os.path.join(KRUHOBOT_FOLDER, 'config.json'), 'r', encoding='utf-8') as f:
|
|
config = json.load(f)
|
|
|
|
logger.info("Loading cogs")
|
|
bot = commands.Bot()
|
|
bot.load_extension('kruhobot.cogs.auth')
|
|
bot.load_extension('kruhobot.cogs.utils')
|
|
|
|
bot.config = config
|
|
bot.logger = logger
|
|
|
|
@bot.listen('on_interaction')
|
|
async def statistics(interaction):
|
|
logger.info(f"{interaction.user} ({interaction.user.id}) used command {interaction.data['name']}.")
|
|
|
|
logger.info("Starting bot")
|
|
bot.run(config["token"])
|