Skip to content

Commit

Permalink
Update config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
FasterSpeeding authored Oct 9, 2024
1 parent ffcea9f commit 4ccc43c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions reinhard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,10 @@ def from_env(cls) -> Self:
dotenv.load_dotenv()

return cls(
# pyright bug
cache=_cast_or_else(os.environ, "CACHE", hikari.api.CacheComponents, DEFAULT_CACHE), # type: ignore
cache=_cast_or_else(os.environ, "CACHE", hikari.api.CacheComponents, DEFAULT_CACHE),
database=DatabaseConfig.from_env(),
emoji_guild=_cast_or_else(os.environ, "EMOJI_GUILD", hikari.Snowflake, None),
# pyright bug
intents=_cast_or_else(os.environ, "INTENTS", hikari.Intents, DEFAULT_INTENTS), # type: ignore
intents=_cast_or_else(os.environ, "INTENTS", hikari.Intents, DEFAULT_INTENTS),
log_level=_cast_or_else(os.environ, "LOG_LEVEL", lambda v: int(v) if v.isdigit() else v, logging.INFO),
mention_prefix=_cast_or_else(os.environ, "MENTION_PREFIX", _str_to_bool, True),
owner_only=_cast_or_else(os.environ, "OWNER_ONLY", _str_to_bool, False),
Expand Down Expand Up @@ -265,12 +263,10 @@ def from_mapping(cls, mapping: collections.Mapping[str, typing.Any], /) -> Self:
declare_global_commands = hikari.Snowflake(declare_global_commands)

return cls(
# pyright bug
cache=_cast_or_else(mapping, "cache", hikari.api.CacheComponents, DEFAULT_CACHE), # type: ignore
cache=_cast_or_else(mapping, "cache", hikari.api.CacheComponents, DEFAULT_CACHE),
database=DatabaseConfig.from_mapping(mapping["database"]),
emoji_guild=_cast_or_else(mapping, "emoji_guild", hikari.Snowflake, None),
# pyright Bug
intents=_cast_or_else(mapping, "intents", hikari.Intents, DEFAULT_INTENTS), # type: ignore
intents=_cast_or_else(mapping, "intents", hikari.Intents, DEFAULT_INTENTS),
log_level=log_level,
mention_prefix=bool(mapping.get("mention_prefix", True)),
owner_only=bool(mapping.get("owner_only", False)),
Expand Down

0 comments on commit 4ccc43c

Please sign in to comment.