paper-dynasty-discord/paperdynasty.py
2023-02-21 16:03:34 -06:00

69 lines
1.7 KiB
Python

import discord
import datetime
import logging
import asyncio
import os
from discord.ext import commands
raw_log_level = os.getenv('LOG_LEVEL')
if raw_log_level == 'DEBUG':
log_level = logging.DEBUG
elif raw_log_level == 'INFO':
log_level = logging.INFO
elif raw_log_level == 'WARN':
log_level = logging.WARNING
else:
log_level = logging.ERROR
date = f'{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}'
logging.basicConfig(
filename=f'logs/discord/{date}.log',
format='%(asctime)s - %(levelname)s - %(message)s',
level=log_level
)
COGS = [
'cogs.owner',
'cogs.admins',
'cogs.economy',
'cogs.players',
'cogs.gameplay',
]
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix='.',
intents=intents,
# help_command=None,
description='The Paper Dynasty Bot\nIf you have questions, feel free to contact Cal.',
case_insensitive=True,
owner_id=258104532423147520)
@bot.event
async def on_ready():
logging.info('Logged in as:')
logging.info(bot.user.name)
logging.info(bot.user.id)
# @bot.tree.error
# async def on_error(interaction, error):
# await interaction.channel.send(f'{error}')
async def main():
for c in COGS:
try:
await bot.load_extension(c)
logging.info(f'Loaded cog: {c}')
except Exception as e:
logging.error(f'Failed to load cog: {c}')
logging.error(f'{e}')
async with bot:
await bot.start(os.environ.get('BOT_TOKEN'))
asyncio.run(main())