diff options
| -rw-r--r-- | arthur/config.py | 4 | ||||
| -rw-r--r-- | arthur/exts/fun/devops_rules.py | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/arthur/config.py b/arthur/config.py index 77748ec..d754696 100644 --- a/arthur/config.py +++ b/arthur/config.py @@ -1,4 +1,6 @@ """Utilities for interacting with the config for King Arthur.""" +from typing import Optional + from pydantic import BaseSettings @@ -21,7 +23,7 @@ class Config(BaseSettings): guild_id: int = 267624335836053506 # Token for authorising with the Notion API - notion_api_token: str + notion_api_token: Optional[str] = None class Config: # noqa: D106 env_file = ".env" diff --git a/arthur/exts/fun/devops_rules.py b/arthur/exts/fun/devops_rules.py index 47d1720..e6be444 100644 --- a/arthur/exts/fun/devops_rules.py +++ b/arthur/exts/fun/devops_rules.py @@ -5,7 +5,7 @@ from typing import TypedDict import discord from discord.ext.commands import Cog, Context, Greedy, command -from arthur.bot import KingArthur +from arthur.bot import KingArthur, logger from arthur.config import CONFIG NOTION_API_BASE_URL = "https://api.notion.com/v1" @@ -91,4 +91,10 @@ class Rules(Cog): async def setup(bot: KingArthur) -> None: """Add cog to bot.""" + if not CONFIG.notion_api_token: + logger.info( + f"Not loading {__name__} as env var " + f"{CONFIG.Config.env_prefix}NOTION_API_TOKEN is not set." + ) + return await bot.add_cog(Rules(bot)) |