2023-03-29 21:37:08 +02:00
|
|
|
#!/usr/bin/env python3
|
2023-03-26 14:13:36 +02:00
|
|
|
from discord.ext import commands
|
2023-04-16 17:38:45 +02:00
|
|
|
import hrochobot.utils.data as data
|
2023-03-30 15:24:01 +02:00
|
|
|
import logging
|
2023-04-16 17:38:45 +02:00
|
|
|
import os
|
2023-03-30 15:24:01 +02:00
|
|
|
|
2023-04-16 17:38:45 +02:00
|
|
|
data.DATA_FOLDER = os.environ.get("HROCHOBOT_DATA", 'data')
|
|
|
|
LOG_FOLDER = os.environ.get("HROCHOBOT_LOG", '.')
|
2023-04-16 18:51:12 +02:00
|
|
|
CONFIG_FOLDER = os.environ.get("HROCHOBOT_ETC", '.')
|
2023-04-16 17:38:45 +02:00
|
|
|
|
|
|
|
logger = logging.getLogger('hrochobot')
|
2023-03-30 15:24:01 +02:00
|
|
|
logger.setLevel(logging.INFO)
|
2023-04-16 18:51:12 +02:00
|
|
|
handler = logging.FileHandler(filename=os.path.join(LOG_FOLDER, 'hrochobot.log'), encoding='utf-8', mode='w')
|
2023-03-30 15:24:01 +02:00
|
|
|
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
|
|
|
|
logger.addHandler(handler)
|
2023-03-26 14:13:36 +02:00
|
|
|
|
2023-04-16 18:51:12 +02:00
|
|
|
CONFIG = data.load_json(os.path.join(CONFIG_FOLDER, "config"))
|
2023-03-26 14:13:36 +02:00
|
|
|
|
|
|
|
bot = commands.Bot()
|
|
|
|
|
|
|
|
cogs_list = [
|
|
|
|
'basic',
|
2023-03-26 14:51:41 +02:00
|
|
|
'roles',
|
2023-03-27 23:32:31 +02:00
|
|
|
'ksp',
|
2023-03-26 14:13:36 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
for cog in cogs_list:
|
2023-04-16 17:38:45 +02:00
|
|
|
bot.load_extension(f'hrochobot.cogs.{cog}')
|
2023-03-26 14:13:36 +02:00
|
|
|
|
2023-03-30 15:55:24 +02:00
|
|
|
@bot.listen('on_interaction')
|
|
|
|
async def statistics(interaction):
|
|
|
|
logger.info(f"{interaction.user} ({interaction.user.id}) used command {interaction.data['name']}.")
|
|
|
|
|
2023-03-26 14:13:36 +02:00
|
|
|
bot.run(CONFIG["token"])
|