Skip to content

Commit bcf7aa1

Browse files
authored
InputText.id
1 parent b0d4ced commit bcf7aa1

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

discord/components.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class InputText(Component):
202202
style: :class:`.InputTextStyle`
203203
The style of the input text field.
204204
custom_id: Optional[:class:`str`]
205-
The ID of the input text field that gets received during an interaction.
205+
The custom ID of the input text field that gets received during an interaction.
206206
label: :class:`str`
207207
The label for the input text field.
208208
placeholder: Optional[:class:`str`]
@@ -216,6 +216,8 @@ class InputText(Component):
216216
Whether the input text field is required or not. Defaults to `True`.
217217
value: Optional[:class:`str`]
218218
The value that has been entered in the input text field.
219+
id: Optional[:class:`int`]
220+
The input text's ID.
219221
"""
220222

221223
__slots__: tuple[str, ...] = (
@@ -228,14 +230,15 @@ class InputText(Component):
228230
"max_length",
229231
"required",
230232
"value",
233+
"id",
231234
)
232235

233236
__repr_info__: ClassVar[tuple[str, ...]] = __slots__
234237
versions: tuple[int, ...] = (1, 2)
235238

236239
def __init__(self, data: InputTextComponentPayload):
237240
self.type = ComponentType.input_text
238-
self.id: int = data.get("id")
241+
self.id: int | None = data.get("id")
239242
self.style: InputTextStyle = try_enum(InputTextStyle, data["style"])
240243
self.custom_id = data["custom_id"]
241244
self.label: str = data.get("label", None)

discord/ui/input_text.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class InputText:
4646
like to control the relative positioning of the row then passing an index is advised.
4747
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
4848
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
49-
id: Optional[:class:`int`]
50-
The input text's ID.
5149
"""
5250

5351
__item_repr_attributes__: tuple[str, ...] = (
@@ -124,6 +122,11 @@ def style(self) -> InputTextStyle:
124122
"""The style of the input text field."""
125123
return self._underlying.style
126124

125+
@property
126+
def id(self) -> int | None:
127+
"""The input text's ID. If not provided by the user, it is set sequentially by Discord."""
128+
return self._underlying.id
129+
127130
@style.setter
128131
def style(self, value: InputTextStyle):
129132
if not isinstance(value, InputTextStyle):

0 commit comments

Comments
 (0)