from services.profile_manager import load_profile, save_profile


def set_description(slot: int, text: str):
    """
    Меняет пользовательское описание.
    slot:
    1 -> Discord description 2
    2 -> Discord description 3
    """

    if slot < 1 or slot > 2:
        raise ValueError(
            "Доступны только описания 1 и 2"
        )


    profile = load_profile()


    descriptions = profile.setdefault(
        "descriptions",
        {
            "1": "",
            "2": "",
            "3": ""
        }
    )


    discord_slot = slot + 1


    descriptions[str(discord_slot)] = text


    profile["descriptions"] = descriptions


    save_profile(profile)


    return text



def get_description(slot: int):

    if slot < 1 or slot > 2:
        raise ValueError(
            "Доступны только описания 1 и 2"
        )


    profile = load_profile()


    descriptions = profile.get(
        "descriptions",
        {}
    )


    discord_slot = slot + 1


    return descriptions.get(
        str(discord_slot),
        ""
    )
