build_develop / build (push) Successful in 34s
lists won't ever happen, but pylance didn't like it.
88 lines
1.8 KiB
Python
88 lines
1.8 KiB
Python
"""File contains classes defining Dakiny settings structure."""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from dataclass_wizard import YAMLWizard
|
|
|
|
CONFIG_LOCATION = "conf/config.yaml"
|
|
|
|
|
|
@dataclass
|
|
class ChannelIds:
|
|
"""Class holds all channel ids needed by bot."""
|
|
|
|
admin: int # might want to rename this...
|
|
announcement: int
|
|
clan_info: int
|
|
event_post: int
|
|
general: int
|
|
voting: int
|
|
|
|
|
|
@dataclass
|
|
class Election:
|
|
"""Class defines relevant election dates."""
|
|
|
|
active: bool
|
|
election_start: str
|
|
highcouncil_election_announce: str
|
|
highcouncil_election_end: str
|
|
highcouncil_election_start: str
|
|
name: str
|
|
term_end: str
|
|
term_start: str
|
|
voting_end: str
|
|
voting_start: str
|
|
|
|
|
|
@dataclass
|
|
class Params:
|
|
"""Class defines start parameters that shouldn't be changed."""
|
|
|
|
discord_token: str
|
|
git_branch: str
|
|
guild_id: int
|
|
|
|
|
|
@dataclass
|
|
class PointSettings:
|
|
"""Class defines point settings editable by Clan Council."""
|
|
|
|
clan_points: int
|
|
clan_points_weekly_limit: int
|
|
events_weekly_limit: int
|
|
host_points: int
|
|
participate_points: int
|
|
verify_clan_points: bool
|
|
verify_events: bool
|
|
|
|
|
|
@dataclass
|
|
class RoleIds:
|
|
"""Class holds all role ids needed by bot."""
|
|
|
|
clan_council: int
|
|
clan_council_elect: int
|
|
clan_member: int
|
|
event_host: int
|
|
high_council: int
|
|
|
|
|
|
@dataclass
|
|
class DakinySettings(YAMLWizard):
|
|
"""Class defines all configs required for Dakiny Bot."""
|
|
|
|
channel_ids: ChannelIds
|
|
election_cycles: list[Election]
|
|
params: Params
|
|
point_settings: PointSettings
|
|
role_ids: RoleIds
|
|
|
|
def save(self) -> None:
|
|
"""Saves settings to the yaml file."""
|
|
self.to_yaml_file(CONFIG_LOCATION)
|
|
|
|
|
|
tmp = DakinySettings.from_yaml_file(CONFIG_LOCATION)
|
|
settings: DakinySettings = tmp[0] if isinstance(tmp, list) else tmp
|