diff options
author | 2021-06-03 15:58:05 +0800 | |
---|---|---|
committer | 2021-06-03 15:58:05 +0800 | |
commit | b60fd23bae52fb59eed0bf29aef2516234d1c858 (patch) | |
tree | 0ed0f44d590e8e4891b2f1ab142b10b48fae2763 /bot/__init__.py | |
parent | Make `setup` docstring same as other cogs (diff) | |
parent | Added "centisecond" in trivia_quiz.json (#751) (diff) |
Merge branch 'main' into feature/pride-leaders
Diffstat (limited to 'bot/__init__.py')
-rw-r--r-- | bot/__init__.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/bot/__init__.py b/bot/__init__.py index bdb18666..85ae4758 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -1,12 +1,23 @@ +try: + from dotenv import load_dotenv + print("Found .env file, loading environment variables from it.") + load_dotenv(override=True) +except ModuleNotFoundError: + pass + import asyncio import logging import logging.handlers import os +from functools import partial, partialmethod from pathlib import Path import arrow +from discord.ext import commands +from bot.command import Command from bot.constants import Client +from bot.group import Group # Configure the "TRACE" logging level (e.g. "log.trace(message)") @@ -56,17 +67,27 @@ if root.handlers: logging.getLogger("discord").setLevel(logging.ERROR) logging.getLogger("websockets").setLevel(logging.ERROR) logging.getLogger("PIL").setLevel(logging.ERROR) +logging.getLogger("matplotlib").setLevel(logging.ERROR) # Setup new logging configuration logging.basicConfig( - format='%(asctime)s - %(name)s %(levelname)s: %(message)s', + format="%(asctime)s - %(name)s %(levelname)s: %(message)s", datefmt="%D %H:%M:%S", level=logging.TRACE if Client.debug else logging.DEBUG, handlers=[console_handler, file_handler], ) -logging.getLogger().info('Logging initialization complete') +logging.getLogger().info("Logging initialization complete") # On Windows, the selector event loop is required for aiodns. if os.name == "nt": asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + + +# Monkey-patch discord.py decorators to use the both the Command and Group subclasses which supports root aliases. +# Must be patched before any cogs are added. +commands.command = partial(commands.command, cls=Command) +commands.GroupMixin.command = partialmethod(commands.GroupMixin.command, cls=Command) + +commands.group = partial(commands.group, cls=Group) +commands.GroupMixin.group = partialmethod(commands.GroupMixin.group, cls=Group) |