From 90d12c884fe2ac0e0bb1b47f0bd746092647f79b Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:36:05 -0500 Subject: [PATCH] utils: fix error logging on 3rd party servers!! --- config.py | 10 ++++++++-- utilities/utilities.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 00bfad99..864a61f7 100644 --- a/config.py +++ b/config.py @@ -138,7 +138,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense # control channel is where maintainence commands are issued bot_control_channel_ids: frozenset # private channel is where stampy logging gets printed -bot_private_channel_id: Optional[str] +bot_private_channel_id: str # NOTE: Rob's invite/member management functions, not ported yet member_role_id: Optional[str] # bot_reboot is how stampy reboots himself @@ -158,6 +158,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense llm_prompt: str be_shy: bool channel_whitelist: Optional[frozenset[str]] +bot_error_channel_id: str is_rob_server = getenv_bool("IS_ROB_SERVER") if is_rob_server: @@ -215,6 +216,10 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense llm_prompt = getenv("LLM_PROMPT", default=stampy_default_prompt) be_shy = getenv_bool("BE_SHY") channel_whitelist = None + bot_error_channel_id = { + "production": "1017527224540344380", + "development": "1017531179664150608" + }[ENVIRONMENT_TYPE] else: # user-configured from dotenv discord_guild = getenv("DISCORD_GUILD") @@ -230,7 +235,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense # control channel is where maintainence commands are issued bot_control_channel_ids = getenv_unique_set("BOT_CONTROL_CHANNEL_IDS", frozenset()) # private channel is where stampy logging gets printed - bot_private_channel_id = getenv("BOT_PRIVATE_CHANNEL_ID", default=None) + bot_private_channel_id = getenv("BOT_PRIVATE_CHANNEL_ID") # NOTE: Rob's invite/member management functions, not ported yet member_role_id = getenv("MEMBER_ROLE_ID", default=None) # bot_reboot is how stampy reboots himself @@ -253,6 +258,7 @@ def getenv_unique_set(var_name: str, default: T = frozenset()) -> Union[frozense llm_prompt = getenv("LLM_PROMPT", default=stampy_default_prompt) be_shy = getenv_bool("BE_SHY") channel_whitelist = getenv_unique_set("CHANNEL_WHITELIST", None) + bot_error_channel_id = getenv("BOT_ERROR_CHANNEL_ID", bot_private_channel_id) discord_token: str = getenv("DISCORD_TOKEN") database_path: str = getenv("DATABASE_PATH") diff --git a/utilities/utilities.py b/utilities/utilities.py index 0c505096..86c1e695 100644 --- a/utilities/utilities.py +++ b/utilities/utilities.py @@ -39,12 +39,12 @@ bot_vip_ids, paid_service_for_all, paid_service_whitelist_role_ids, - be_shy + be_shy, + bot_error_channel_id ) from database.database import Database from servicemodules.discordConstants import ( wiki_feed_channel_id, - stampy_error_log_channel_id, ) from servicemodules.serviceConstants import Services from utilities.discordutils import DiscordUser, user_has_role @@ -291,7 +291,7 @@ async def log_exception( def error_channel(self) -> discord.channel.TextChannel: return cast( discord.channel.TextChannel, - self.client.get_channel(int(stampy_error_log_channel_id)), + self.client.get_channel(int(bot_error_channel_id)), ) async def log_error(self, error_message: str) -> None: