From 4716123f6bfd2af7ade27115e906c26cf6ce5208 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Fri, 7 Oct 2022 13:54:54 +0100 Subject: Add devops rules command --- arthur/config.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arthur/config.py') diff --git a/arthur/config.py b/arthur/config.py index 1fcf11d..77748ec 100644 --- a/arthur/config.py +++ b/arthur/config.py @@ -20,6 +20,9 @@ class Config(BaseSettings): # Guild id guild_id: int = 267624335836053506 + # Token for authorising with the Notion API + notion_api_token: str + class Config: # noqa: D106 env_file = ".env" env_prefix = "KING_ARTHUR_" -- cgit v1.2.3 From d475961e051751c3b2d0dd9efdded86093a895c4 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Fri, 7 Oct 2022 21:04:41 +0100 Subject: Don't load devops rules if notion api key isn't set --- arthur/config.py | 4 +++- arthur/exts/fun/devops_rules.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'arthur/config.py') 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)) -- cgit v1.2.3