Skip to content

Commit

Permalink
utils: fix error logging on 3rd party servers!!
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt committed Sep 20, 2023
1 parent 12fb944 commit 90d12c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 90d12c8

Please sign in to comment.