Skip to content

Commit

Permalink
Simplify TagEditorModal
Browse files Browse the repository at this point in the history
  • Loading branch information
hypergonial committed Nov 9, 2023
1 parent d9375a0 commit 1bc650b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions extensions/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, name: str | None = None, content: str | None = None) -> None:
self.add_item(
miru.TextInput(
label="Tag Name",
custom_id="name",
placeholder="Enter a tag name...",
required=True,
min_length=3,
Expand All @@ -41,6 +42,7 @@ def __init__(self, name: str | None = None, content: str | None = None) -> None:
self.add_item(
miru.TextInput(
label="Tag Content",
custom_id="content",
style=hikari.TextInputStyle.PARAGRAPH,
placeholder="Enter tag content, supports markdown formatting...",
required=True,
Expand All @@ -56,12 +58,8 @@ async def callback(self, ctx: miru.ModalContext) -> None:
if not ctx.values:
return

for item, value in ctx.values.items():
assert isinstance(item, miru.TextInput)
if item.label == "Tag Name":
self.tag_name = value
elif item.label == "Tag Content":
self.tag_content = value
self.tag_name = ctx.get_value_by_id("name", default="")
self.tag_content = ctx.get_value_by_id("content")


@tags.command
Expand Down

0 comments on commit 1bc650b

Please sign in to comment.