mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-06 18:11:59 +00:00
Rename default_value to default for TextInput
This commit is contained in:
parent
2c72fc9cde
commit
e56f64218a
@ -391,7 +391,7 @@ class TextInput(Component):
|
|||||||
The style of the text input.
|
The style of the text input.
|
||||||
placeholder: Optional[:class:`str`]
|
placeholder: Optional[:class:`str`]
|
||||||
The placeholder text to display when the text input is empty.
|
The placeholder text to display when the text input is empty.
|
||||||
default_value: Optional[:class:`str`]
|
value: Optional[:class:`str`]
|
||||||
The default value of the text input.
|
The default value of the text input.
|
||||||
required: :class:`bool`
|
required: :class:`bool`
|
||||||
Whether the text input is required.
|
Whether the text input is required.
|
||||||
@ -406,7 +406,7 @@ class TextInput(Component):
|
|||||||
'label',
|
'label',
|
||||||
'custom_id',
|
'custom_id',
|
||||||
'placeholder',
|
'placeholder',
|
||||||
'default_value',
|
'value',
|
||||||
'required',
|
'required',
|
||||||
'min_length',
|
'min_length',
|
||||||
'max_length',
|
'max_length',
|
||||||
@ -420,7 +420,7 @@ class TextInput(Component):
|
|||||||
self.label: str = data['label']
|
self.label: str = data['label']
|
||||||
self.custom_id: str = data['custom_id']
|
self.custom_id: str = data['custom_id']
|
||||||
self.placeholder: Optional[str] = data.get('placeholder')
|
self.placeholder: Optional[str] = data.get('placeholder')
|
||||||
self.default_value: Optional[str] = data.get('value')
|
self.value: Optional[str] = data.get('value')
|
||||||
self.required: bool = data.get('required', True)
|
self.required: bool = data.get('required', True)
|
||||||
self.min_length: Optional[int] = data.get('min_length')
|
self.min_length: Optional[int] = data.get('min_length')
|
||||||
self.max_length: Optional[int] = data.get('max_length')
|
self.max_length: Optional[int] = data.get('max_length')
|
||||||
@ -437,8 +437,8 @@ class TextInput(Component):
|
|||||||
if self.placeholder:
|
if self.placeholder:
|
||||||
payload['placeholder'] = self.placeholder
|
payload['placeholder'] = self.placeholder
|
||||||
|
|
||||||
if self.default_value:
|
if self.value:
|
||||||
payload['value'] = self.default_value
|
payload['value'] = self.value
|
||||||
|
|
||||||
if self.min_length:
|
if self.min_length:
|
||||||
payload['min_length'] = self.min_length
|
payload['min_length'] = self.min_length
|
||||||
@ -448,6 +448,14 @@ class TextInput(Component):
|
|||||||
|
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default(self) -> Optional[str]:
|
||||||
|
"""Optional[:class:`str`]: The default value of the text input.
|
||||||
|
|
||||||
|
This is an alias to :attr:`value`.
|
||||||
|
"""
|
||||||
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
def _component_factory(data: ComponentPayload) -> Component:
|
def _component_factory(data: ComponentPayload) -> Component:
|
||||||
component_type = data['type']
|
component_type = data['type']
|
||||||
|
@ -65,7 +65,7 @@ class TextInput(Item[V]):
|
|||||||
The style of the text input.
|
The style of the text input.
|
||||||
placeholder: Optional[:class:`str`]
|
placeholder: Optional[:class:`str`]
|
||||||
The placeholder text to display when the text input is empty.
|
The placeholder text to display when the text input is empty.
|
||||||
default_value: Optional[:class:`str`]
|
default: Optional[:class:`str`]
|
||||||
The default value of the text input.
|
The default value of the text input.
|
||||||
required: :class:`bool`
|
required: :class:`bool`
|
||||||
Whether the text input is required.
|
Whether the text input is required.
|
||||||
@ -94,14 +94,14 @@ class TextInput(Item[V]):
|
|||||||
style: TextStyle = TextStyle.short,
|
style: TextStyle = TextStyle.short,
|
||||||
custom_id: str = MISSING,
|
custom_id: str = MISSING,
|
||||||
placeholder: Optional[str] = None,
|
placeholder: Optional[str] = None,
|
||||||
default_value: Optional[str] = None,
|
default: Optional[str] = None,
|
||||||
required: bool = True,
|
required: bool = True,
|
||||||
min_length: Optional[int] = None,
|
min_length: Optional[int] = None,
|
||||||
max_length: Optional[int] = None,
|
max_length: Optional[int] = None,
|
||||||
row: Optional[int] = None,
|
row: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._value: Optional[str] = default_value
|
self._value: Optional[str] = default
|
||||||
self._provided_custom_id = custom_id is not MISSING
|
self._provided_custom_id = custom_id is not MISSING
|
||||||
custom_id = os.urandom(16).hex() if custom_id is MISSING else custom_id
|
custom_id = os.urandom(16).hex() if custom_id is MISSING else custom_id
|
||||||
self._underlying = TextInputComponent._raw_construct(
|
self._underlying = TextInputComponent._raw_construct(
|
||||||
@ -110,7 +110,7 @@ class TextInput(Item[V]):
|
|||||||
style=style,
|
style=style,
|
||||||
custom_id=custom_id,
|
custom_id=custom_id,
|
||||||
placeholder=placeholder,
|
placeholder=placeholder,
|
||||||
default_value=default_value,
|
value=default,
|
||||||
required=required,
|
required=required,
|
||||||
min_length=min_length,
|
min_length=min_length,
|
||||||
max_length=max_length,
|
max_length=max_length,
|
||||||
@ -193,13 +193,13 @@ class TextInput(Item[V]):
|
|||||||
self._underlying.style = value
|
self._underlying.style = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_value(self) -> Optional[str]:
|
def default(self) -> Optional[str]:
|
||||||
""":class:`str`: The default value of the text input."""
|
""":class:`str`: The default value of the text input."""
|
||||||
return self._underlying.default_value
|
return self._underlying.value
|
||||||
|
|
||||||
@default_value.setter
|
@default.setter
|
||||||
def default_value(self, value: Optional[str]) -> None:
|
def default(self, value: Optional[str]) -> None:
|
||||||
self._underlying.default_value = value
|
self._underlying.value = value
|
||||||
|
|
||||||
def to_component_dict(self) -> TextInputPayload:
|
def to_component_dict(self) -> TextInputPayload:
|
||||||
return self._underlying.to_dict()
|
return self._underlying.to_dict()
|
||||||
@ -217,7 +217,7 @@ class TextInput(Item[V]):
|
|||||||
style=component.style,
|
style=component.style,
|
||||||
custom_id=component.custom_id,
|
custom_id=component.custom_id,
|
||||||
placeholder=component.placeholder,
|
placeholder=component.placeholder,
|
||||||
default_value=component.default_value,
|
default=component.value,
|
||||||
required=component.required,
|
required=component.required,
|
||||||
min_length=component.min_length,
|
min_length=component.min_length,
|
||||||
max_length=component.max_length,
|
max_length=component.max_length,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user