Skip to content

Commit 8765c51

Browse files
authored
fix: make list an enum instead of raw str field (#98)
1 parent 84630a2 commit 8765c51

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

byte_bot/server/domain/guilds/controllers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
GitHubConfigSchema,
2323
GuildSchema,
2424
SOTagsConfigSchema,
25+
UpdateableGuildSettingEnum,
2526
)
2627
from byte_bot.server.domain.guilds.services import (
2728
AllowedUsersConfigService, # noqa: TC001
@@ -118,7 +119,7 @@ async def update_guild(
118119
title="Guild ID",
119120
description="The guild ID.",
120121
),
121-
setting: str = Parameter(
122+
setting: UpdateableGuildSettingEnum = Parameter( # type: ignore[valid-type]
122123
title="Setting",
123124
description="The setting to update.",
124125
),
@@ -141,7 +142,7 @@ async def update_guild(
141142
result = await guilds_service.get(guild_id, id_attribute="guild_id")
142143
# todo: this is a placeholder, update to grab whichever setting is being update, and update the corresponding
143144
# tables value based on the setting parameter
144-
await guilds_service.update({setting: value}, item_id=guild_id)
145+
await guilds_service.update({setting.value: value}, item_id=guild_id)
145146
return guilds_service.to_schema(schema_type=GuildSchema, data=result)
146147

147148
@get(

byte_bot/server/domain/guilds/schemas.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from enum import Enum
56
from uuid import UUID # noqa: TC003
67

78
from pydantic import Field
@@ -17,6 +18,7 @@
1718
"GuildUpdate",
1819
"SOTagsConfigSchema",
1920
"UpdateableGuildSetting",
21+
"UpdateableGuildSettingEnum",
2022
)
2123

2224

@@ -172,3 +174,10 @@ class UpdateableGuildSetting(CamelizedBaseModel):
172174
showcase_thread_auto_close_days: int = Field(
173175
title="Showcase Thread Auto Close Days", description="The days to auto close showcase threads after inactivity."
174176
)
177+
178+
179+
# idk
180+
UpdateableGuildSettingEnum = Enum( # type: ignore[misc]
181+
"UpdateableGuildSettingEnum",
182+
{field_name.upper(): field_name for field_name in UpdateableGuildSetting.model_fields},
183+
)

0 commit comments

Comments
 (0)