Archived
generated from imcompiling/discord-bot-template
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""File contains classes defining off-cooldown-bot 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."""
|
||||
|
||||
general: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class Params:
|
||||
"""Class defines start parameters that shouldn't be changed."""
|
||||
|
||||
discord_token: str
|
||||
guild_id: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class Settings(YAMLWizard):
|
||||
"""Class defines all configs required for off-cooldown-bot."""
|
||||
|
||||
channel_ids: ChannelIds
|
||||
params: Params
|
||||
|
||||
def save(self) -> None:
|
||||
"""Save settings to the yaml file."""
|
||||
self.to_yaml_file(CONFIG_LOCATION)
|
||||
|
||||
|
||||
settings = Settings.from_yaml_file(CONFIG_LOCATION)
|
||||
|
||||
# I'm not expecting a list to be returned.
|
||||
if isinstance(settings, list):
|
||||
settings = settings[0]
|
||||
Reference in New Issue
Block a user