Kruhobot/bin/kruhobot

30 lines
912 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)
with open(os.path.join(KRUHOBOT_FOLDER, 'config.json'), 'r', encoding='utf-8') as f:
config = json.load(f)
bot = commands.Bot()
bot.load_extension('kruhobot.cogs.auth')
bot.load_extension('kruhobot.cogs.utils')
bot.tree.sync()
@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"])