From 0875891c314b1a3c39073f2c3c656581851a0f8a Mon Sep 17 00:00:00 2001 From: No767 <73260931+No767@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:20:22 -0800 Subject: [PATCH] RGet rodhaj entries and fix broken config code --- bot/libs/utils/config.py | 4 ++++ bot/migrations.py | 8 ++++++-- bot/rodhaj.py | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bot/libs/utils/config.py b/bot/libs/utils/config.py index 403f096..e98c564 100644 --- a/bot/libs/utils/config.py +++ b/bot/libs/utils/config.py @@ -19,6 +19,10 @@ def load_from_file(self) -> None: except FileNotFoundError: self._config = {} + @property + def rodhaj(self) -> _T: + return self._config.get("rodhaj", {}) + @overload def get(self, key: Any) -> Optional[Union[_T, Any]]: ... diff --git a/bot/migrations.py b/bot/migrations.py index 114118d..4210dc0 100644 --- a/bot/migrations.py +++ b/bot/migrations.py @@ -10,9 +10,13 @@ import asyncpg import click from libs.utils.config import RodhajConfig -from typing_extensions import Self -path = Path(__file__).parent / "config.json" +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +path = Path(__file__).parent / "config.yml" config = RodhajConfig(path) BE = TypeVar("BE", bound=BaseException) diff --git a/bot/rodhaj.py b/bot/rodhaj.py index b87b66d..e1428c2 100644 --- a/bot/rodhaj.py +++ b/bot/rodhaj.py @@ -57,10 +57,10 @@ def __init__( self.partial_config: Optional[PartialConfig] = None self.pool = pool self.version = str(VERSION) - self.transprogrammer_guild_id = config["rodhaj"].get( + self.transprogrammer_guild_id = config.rodhaj.get( "guild_id", 1183302385020436480 ) - self._dev_mode = config["rodhaj"].get("dev_mode", False) + self._dev_mode = config.rodhaj.get("dev_mode", False) self._reloader = Reloader(self, Path(__file__).parent) ### Ticket related utils