Skip to content

Commit c2bd6b5

Browse files
authored
further consolidate
1 parent fbac652 commit c2bd6b5

File tree

13 files changed

+24
-22
lines changed

13 files changed

+24
-22
lines changed

discord/ui/action_row.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def walk_items(self) -> Iterator[ViewItem]:
389389

390390
def to_component_dict(self) -> ActionRowPayload:
391391
self._set_components(self.items)
392-
return self._underlying.to_dict()
392+
return super().to_component_dict()
393393

394394
@classmethod
395395
def from_component(cls: type[A], component: ActionRowComponent) -> A:

discord/ui/button.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
if TYPE_CHECKING:
4343
from ..emoji import AppEmoji, GuildEmoji
4444
from .view import BaseView
45+
from ..types.components import ButtonComponent as ButtonComponentPayload
4546

4647
B = TypeVar("B", bound="Button")
4748
V = TypeVar("V", bound="BaseView", covariant=True)
@@ -263,8 +264,8 @@ def from_component(cls: type[B], button: ButtonComponent) -> B:
263264
id=button.id,
264265
)
265266

266-
def to_component_dict(self):
267-
return self._underlying.to_dict()
267+
def to_component_dict(self) -> ButtonComponentPayload:
268+
return super().to_component_dict()
268269

269270
def is_dispatchable(self) -> bool:
270271
return self.custom_id is not None

discord/ui/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def walk_items(self) -> Iterator[ViewItem]:
402402

403403
def to_component_dict(self) -> ContainerComponentPayload:
404404
self._set_components(self.items)
405-
return self._underlying.to_dict()
405+
return super().to_component_dict()
406406

407407
@classmethod
408408
def from_component(cls: type[C], component: ContainerComponent) -> C:

discord/ui/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def refresh_component(self, component: FileComponent) -> None:
8888
self._underlying = component
8989

9090
def to_component_dict(self) -> FileComponentPayload:
91-
return self._underlying.to_dict()
91+
return super().to_component_dict()
9292

9393
@classmethod
9494
def from_component(cls: type[F], component: FileComponent) -> F:

discord/ui/input_text.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ def style(self) -> InputTextStyle:
120120
"""The style of the input text field."""
121121
return self._underlying.style
122122

123-
@property
124-
def id(self) -> int | None:
125-
"""The input text's ID. If not provided by the user, it is set sequentially by Discord."""
126-
return self._underlying.id
127-
128123
@style.setter
129124
def style(self, value: InputTextStyle):
130125
if not isinstance(value, InputTextStyle):
@@ -225,8 +220,12 @@ def value(self, value: str | None):
225220
raise ValueError("value must be 4000 characters or fewer")
226221
self._underlying.value = value
227222

223+
@property
224+
def width(self) -> int:
225+
return 5
226+
228227
def to_component_dict(self) -> InputTextComponentPayload:
229-
return self._underlying.to_dict()
228+
return super().to_component_dict()
230229

231230
def refresh_state(self, data) -> None:
232231
self._input_value = data["value"]

discord/ui/item.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def __init__(self):
8181
self.parent: Item | ItemInterface | None = None
8282

8383
def to_component_dict(self) -> dict[str, Any]:
84-
raise NotImplementedError
84+
if not self._underlying:
85+
raise NotImplementedError
86+
return self._underlying.to_dict()
8587

8688
def refresh_component(self, component: Component) -> None:
8789
self._underlying = component

discord/ui/label.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ..emoji import AppEmoji, GuildEmoji
2121
from ..interaction import Interaction
2222
from ..partial_emoji import PartialEmoji, _EmojiTag
23-
from ..types.components import Label as LabelPayload
23+
from ..types.components import LabelComponent as LabelComponentPayload
2424
from .modal import DesignerModal
2525

2626

@@ -335,11 +335,11 @@ def refresh_component(self, component: LabelComponent) -> None:
335335
def walk_items(self) -> Iterator[ModalItem]:
336336
yield from [self.item]
337337

338-
def to_component_dict(self) -> LabelPayload:
338+
def to_component_dict(self) -> LabelComponentPayload:
339339
self._set_component_from_item(self.item)
340-
return self._underlying.to_dict()
340+
return super().to_component_dict()
341341

342-
def refresh_from_modal(self, interaction: Interaction, data: LabelPayload) -> None:
342+
def refresh_from_modal(self, interaction: Interaction, data: LabelComponentPayload) -> None:
343343
return self.item.refresh_from_modal(interaction, data.get("component", {}))
344344

345345
@classmethod

discord/ui/media_gallery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def add_item(
106106
return self.append_item(item)
107107

108108
def to_component_dict(self) -> MediaGalleryComponentPayload:
109-
return self._underlying.to_dict()
109+
return super().to_component_dict()
110110

111111
@classmethod
112112
def from_component(cls: type[M], component: MediaGalleryComponent) -> M:

discord/ui/section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def to_component_dict(self) -> SectionComponentPayload:
309309
self._set_components(self.items)
310310
if self.accessory:
311311
self.set_accessory(self.accessory)
312-
return self._underlying.to_dict()
312+
return super().to_component_dict()
313313

314314
@classmethod
315315
def from_component(cls: type[S], component: SectionComponent) -> S:

discord/ui/select.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def width(self) -> int:
714714
return 5
715715

716716
def to_component_dict(self) -> SelectMenuPayload:
717-
return self._underlying.to_dict()
717+
return super().to_component_dict()
718718

719719
def refresh_component(self, component: SelectMenu) -> None:
720720
self._underlying = component

0 commit comments

Comments
 (0)