Component

Represents a message component.

Attributes

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

Returns the component's style.

Returns

style : None, ButtonStyle, TextInputStyle

text_input_style

url

value

Methods

__new__(component_type, ...)

Creates a component with the given parameters.

ParameterTypeOptionalKeyword onlyDescription
component_type

int, ComponentType

The component's type to create.

**keyword_parameters

Keyword parameters

Keyword parameters defining the component's fields.

button_style

ButtonStyle

The component's style. Applicable for button components.

channel_types

None, tuple of (ChannelType, int)

The allowed channel types by the select.

components

None, tuple of Component

Sub-components.

custom_id

None, str

Custom identifier to detect which component was clicked (or used) by the user.

default_values

None | iterable<Channel | Role | ClientUserBase | EntitySelectDefaultValue | tuple>

Entities presented in the select by default.

emoji

None Emoji

Emoji of the component if applicable.

enabled

bool

Whether the component is enabled.

label

None, str

Label of the component.

max_length

int

The maximal length of the inputted text.

max_values

int

The maximal amount of options to select.

min_length

int

The minimal length of the inputted text.

min_values

int

The minimal amount of options to select.

options

None, tuple of StringSelectOption

Options of the component.

placeholder

None, str

Placeholder of the select.

required

bool

Whether the field is required to be fulfilled.

text_input_style

TextInputStyle

The text input's style.

url

None, str

Url to redirect to.

value

None, str

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.

copy()

Copies the component.

Returns

new : instance<type<self>>

copy_with(...)

Copies the component with changing it's field.

ParameterTypeOptionalKeyword onlyDescription
component_type

int, ComponentType

The component's type.

**keyword_parameters

Keyword parameters

Keyword parameters defining which fields should be changed.

button_style

ButtonStyle

The component's style. Applicable for button components.

channel_types

None, tuple of (ChannelType, int)

The allowed channel types by the select.

components

None, tuple of Component

Sub-components.

custom_id

None, str

Custom identifier to detect which component was clicked (or used) by the user.

default_values

None | iterable<Channel | Role | ClientUserBase | EntitySelectDefaultValue | tuple>

Entities presented in the select by default.

emoji

None Emoji

Emoji of the component if applicable.

enabled

bool

Whether the component is enabled.

label

None, str

Label of the component.

max_length

int

The maximal length of the inputted text.

max_values

int

The maximal amount of options to select.

min_length

int

The minimal length of the inputted text.

min_values

int

The minimal amount of options to select.

options

None, tuple of StringSelectOption

Options of the component.

placeholder

None, str

Placeholder of the select.

required

bool

Whether the field is required to be fulfilled.

text_input_style

TextInputStyle

The text input's style.

url

None, str

Url to redirect to.

value

None, str

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.

from_data(data)

Creates a component from the given data.

ParameterTypeDescription
data

dict of (str, object) items

Component data.

Returns

self : instance<cls>

Returns the created component.

iter_components()

Iterates over the direct sub-components of the component.

This method is an iterable generator.

Yields

component : Component

iter_default_values()

Iterates over the default options of the component.

This method is an iterable generator.

Yields

default_value : EntitySelectDefaultValue

iter_options()

Iterates over the options of the component.

This method is an iterable generator.

Yields

option : StringSelectOption

to_data(...)

Returns the component's json serializable representation.

ParameterTypeOptionalKeyword onlyDefaultDescription
defaults

bool

False

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.