Component
Represents a message component.
Attributes metadata :
The component's metadata.
The component's type.
Properties
button_style
channel_types
components
custom_id
default_values
emoji
enabled
label
max_length
max_values
min_length
min_values
options
placeholder
required
style
text_input_style
url
value
Methods
(component_type, ...)
__new__Creates a component with the given parameters.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
component_type |
| The component's type to create. | ||
**keyword_parameters | Keyword parameters | Keyword parameters defining the component's fields. | ||
button_style | The component's style. Applicable for button components. | |||
channel_types |
| The allowed channel types by the select. | ||
components |
| Sub-components. | ||
custom_id |
| Custom identifier to detect which component was clicked (or used) by the user. | ||
default_values |
| Entities presented in the select by default. | ||
emoji |
| Emoji of the component if applicable. | ||
enabled |
| Whether the component is enabled. | ||
label |
| Label of the component. | ||
max_length |
| The maximal length of the inputted text. | ||
max_values |
| The maximal amount of options to select. | ||
min_length |
| The minimal length of the inputted text. | ||
min_values |
| The minimal amount of options to select. | ||
options |
| Options of the component. | ||
placeholder |
| Placeholder of the select. | ||
required |
| Whether the field is required to be fulfilled. | ||
text_input_style | The text input's style. | |||
url |
| Url to redirect to. | ||
value |
| The input component's default value. |
Raises
TypeError
- If a parameter's type is incorrect.
- Extra or unused parameters.
ValueError
- If a parameter's value is incorrect.
()
copyCopies the component.
Returns
new : instance<type<self>>
(...)
copy_withCopies the component with changing it's field.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
component_type |
| The component's type. | ||
**keyword_parameters | Keyword parameters | Keyword parameters defining which fields should be changed. | ||
button_style | The component's style. Applicable for button components. | |||
channel_types |
| The allowed channel types by the select. | ||
components |
| Sub-components. | ||
custom_id |
| Custom identifier to detect which component was clicked (or used) by the user. | ||
default_values |
| Entities presented in the select by default. | ||
emoji |
| Emoji of the component if applicable. | ||
enabled |
| Whether the component is enabled. | ||
label |
| Label of the component. | ||
max_length |
| The maximal length of the inputted text. | ||
max_values |
| The maximal amount of options to select. | ||
min_length |
| The minimal length of the inputted text. | ||
min_values |
| The minimal amount of options to select. | ||
options |
| Options of the component. | ||
placeholder |
| Placeholder of the select. | ||
required |
| Whether the field is required to be fulfilled. | ||
text_input_style | The text input's style. | |||
url |
| Url to redirect to. | ||
value |
| The input component's default value. |
Returns
new : instance<type<self>>
Raises
TypeError
- If a parameter's type is incorrect.
- Extra or unused parameters.
ValueError
- If a parameter's value is incorrect.
(data)
from_dataCreates a component from the given data.
Parameter | Type | Description |
---|---|---|
data |
| Component data. |
Returns
self : instance<cls>
Returns the created component.
()
iter_componentsIterates over the direct sub-components of the component.
This method is an iterable generator.
Yields
component : Component
()
iter_default_valuesIterates over the default options of the component.
This method is an iterable generator.
Yields
default_value : EntitySelectDefaultValue
()
iter_optionsIterates over the options of the component.
This method is an iterable generator.
Yields
option : StringSelectOption
(...)
to_dataReturns the component's json serializable representation.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
defaults |
|
| Whether fields with default values should be included as well. |
Returns
data : dict
of (str
, object
) items
()
__eq__Returns whether the two components are equal.
()
__getattr__Drops a rich attribute error.
()
__hash__Returns the component's hash value.
()
__iter__Iterates over the sub components.
This method is an iterable generator.
Yields
component
()
__repr__Returns the component's representation.