diff --git a/main.py b/main.py index 1b9a51d..963d288 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,8 @@ import os import nextcord from nextcord.ext import commands +from settings import settings + nextcord_logger = logging.getLogger("nextcord") nextcord_logger.setLevel(logging.DEBUG) nextcord_handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w") @@ -49,7 +51,7 @@ def main() -> None: print(f"{bot.user.name} has connected to Discord!") # Run Discord bot - bot.run(bot.config.params.discord_token) + bot.run(settings.params.discord_token) if __name__ == "__main__": diff --git a/pyproject.toml b/pyproject.toml index 572a70d..18771ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,13 +5,10 @@ description = "" authors = [{name="${REPO_OWNER}", email=""}] readme = "README.md" dependencies = [ - "cryptography>=43.0.3", "nextcord>=2.6.0", - "pandas>=2.2.3", - "pymysql>=1.1.1", "python-dotenv>=1.0.1", - "setuptools>=75.3.0", "sqlmodel>=0.0.22", + "dataclass-wizard[yaml]>=0.22.3,<1.0.0", ] requires-python = ">=3.12" diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..0c78f77 --- /dev/null +++ b/settings.py @@ -0,0 +1,28 @@ +"""File contains classes defining ${REPO_NAME} settings structure.""" + +from dataclasses import dataclass + +from dataclass_wizard import YAMLWizard + +CONFIG_LOCATION = "conf/config.yaml" + + +@dataclass +class Params: + """Class defines start parameters that shouldn't be changed.""" + + discord_token: str + + +@dataclass +class Settings(YAMLWizard): + """Class defines all configs required for ${REPO_NAME}.""" + + 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)