From 7e1a3b3e77d5fc557db7da459643e42dfecc8ea8 Mon Sep 17 00:00:00 2001 From: evansteelepdx Date: Tue, 19 Apr 2022 16:25:59 -0700 Subject: [PATCH] make Loki configuration optional - rolled back previous commit - fewer checks for loki configuration keys --- cogs/general.py | 7 +++++-- utils/tools/settings.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cogs/general.py b/cogs/general.py index fdeee26f..933aa7fd 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -81,7 +81,9 @@ def get_docs_keys(): docs_data = load_md_as_dict(settings.resource("docs.md")) return list(docs_data.keys()) -LOKI_APPLICATION_NAME = settings.loki["application"] +if settings.loki: + LOKI_APPLICATION_NAME = settings.loki["application"] + class BotStats(): server_count: int user_count: int @@ -533,7 +535,8 @@ async def docs(self, inter: disnake.CommandInteraction, topic: str = commands.Pa async def update_botstats(self): logger.info("task_triggered: update_botstats()") try: - await self.botstats_weekly.update(self.bot) + if LOKI_APPLICATION_NAME: + await self.botstats_weekly.update(self.bot) except Exception as e: await report_error("update_botstats()", e) diff --git a/utils/tools/settings.py b/utils/tools/settings.py index fd1ef245..b836d888 100644 --- a/utils/tools/settings.py +++ b/utils/tools/settings.py @@ -12,7 +12,7 @@ class Settings: def __init__(self): self.path = "settings.json" - self.defaults = OrderedDict([ ("token", ""), ("error_logging", False), ("debug", False) ]) + self.defaults = OrderedDict([ ("token", ""), ("error_logging", False), ("debug", False), ("loki", OrderedDict([ ("base_url", ""), ("application", ""), ("username", ""), ("password","") ]))]) if not os.path.exists(self.path): self.json_data = self.defaults self.save_settings()