84 lines
1.6 KiB
Python
84 lines
1.6 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 EventSettings:
|
|
"""Class defines settings editable by Clan Council."""
|
|
|
|
host_points: int
|
|
participate_points: int
|
|
verify: bool
|
|
weekly_limit: int
|
|
|
|
|
|
@dataclass
|
|
class Params:
|
|
"""Class defines start parameters that shouldn't be changed."""
|
|
|
|
discord_token: str
|
|
git_branch: str
|
|
guild_id: int
|
|
|
|
|
|
@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]
|
|
event_settings: EventSettings
|
|
params: Params
|
|
role_ids: RoleIds
|
|
|
|
def save(self) -> None:
|
|
"""Saves settings to the yaml file."""
|
|
self.to_yaml_file(CONFIG_LOCATION)
|
|
|
|
|
|
settings = DakinySettings.from_yaml_file(CONFIG_LOCATION)
|