Components API¶
Note
The following classes come from the discord.parts.action_row
module.
ActionRow
dataclass
¶
Bases: DataModel
, ContainerChild
Represents a container of interactable components.
components: list[ActionRowChild] = field(default_factory=list)
class-attribute
instance-attribute
¶
add_button
¶
Add a button to this action row. (5 per row)
Parameters:
-
style
(Literal['Primary', 'Secondary', 'Success', 'Danger', 'Link']
) –button style as a string
-
label
(str
) –button text
-
custom_id
(str
) –developer-defined button ID
-
emoji
((str | EmojiModel, Optional)
, default:None
) –str if unicode emoji, EmojiModal if custom
-
disable
((bool, Optional)
, default:False
) –if this button should be pressable. Defaults to False.
Returns:
-
ActionRow
–self
string_select
¶
Add a string select to this action row. (1 per row)
Parameters:
-
select
(StringSelect
) –the StringSelect option object
Returns:
-
ActionRow
–self
user_select
¶
Add a user select to this action row. (1 per row)
Parameters:
-
select
(UserSelect
) –the UserSelect option object
Returns:
-
ActionRow
–self
role_select
¶
Add a role select to this action row. (1 per row)
Parameters:
-
select
(RoleSelect
) –the RoleSelect option object
Returns:
-
ActionRow
–self
channel_select
¶
Add a channel select to this action row. (1 per row)
Parameters:
-
select
(ChannelSelect
) –the ChannelSelect option object
Returns:
-
ActionRow
–self
mentionable_select
¶
Add a mentionable select to this action row. (1 per row)
Parameters:
-
select
(MentionableSelect
) –the MentionableSelect option object
Returns:
-
ActionRow
–self
StringSelect
dataclass
¶
Bases: DataModel
, ActionRowChild
, LabelChild
Represents the String Select component.
custom_id: str
instance-attribute
¶
options: list[_SelectOption] = field(default_factory=list)
class-attribute
instance-attribute
¶
placeholder: Optional[str] = None
class-attribute
instance-attribute
¶
min_values: Optional[int] = 0
class-attribute
instance-attribute
¶
max_values: Optional[int] = 1
class-attribute
instance-attribute
¶
required: Optional[bool] = False
class-attribute
instance-attribute
¶
disabled: Optional[bool] = False
class-attribute
instance-attribute
¶
add_option
¶
Add an option to this string select component.
Parameters:
-
label
(str
) –option text
-
value
(str
) –analogous to button's custom ID
-
description
(str
, default:None
) –option subtext
-
emoji
(str | EmojiModel
, default:None
) –string if unicode emoji, EmojiModel if custom
-
default
(bool
, default:False
) –if this option should be the default option. Defaults to False.
Returns:
-
StringSelect
–self
UserSelect
dataclass
¶
Bases: DataModel
, ActionRowChild
Represents the User Select component.
custom_id: str
instance-attribute
¶
placeholder: Optional[str] = None
class-attribute
instance-attribute
¶
default_values: list[_DefaultValue] = field(default_factory=list)
class-attribute
instance-attribute
¶
min_values: Optional[int] = 0
class-attribute
instance-attribute
¶
max_values: Optional[int] = 1
class-attribute
instance-attribute
¶
disabled: Optional[bool] = False
class-attribute
instance-attribute
¶
add_default_value
¶
RoleSelect
dataclass
¶
Bases: DataModel
, ActionRowChild
Represents the Role Select component.
custom_id: str
instance-attribute
¶
placeholder: Optional[str] = None
class-attribute
instance-attribute
¶
default_values: list[_DefaultValue] = field(default_factory=list)
class-attribute
instance-attribute
¶
min_values: Optional[int] = 0
class-attribute
instance-attribute
¶
max_values: Optional[int] = 1
class-attribute
instance-attribute
¶
disabled: Optional[bool] = False
class-attribute
instance-attribute
¶
add_default_value
¶
ChannelSelect
dataclass
¶
Bases: DataModel
, ActionRowChild
Represents the Channel Select component.
custom_id: str
instance-attribute
¶
placeholder: Optional[str] = None
class-attribute
instance-attribute
¶
default_values: list[_DefaultValue] = field(default_factory=list)
class-attribute
instance-attribute
¶
min_values: Optional[int] = 0
class-attribute
instance-attribute
¶
max_values: Optional[int] = 1
class-attribute
instance-attribute
¶
disabled: Optional[bool] = False
class-attribute
instance-attribute
¶
add_default_value
¶
MentionableSelect
dataclass
¶
Bases: DataModel
, ActionRowChild
Represents the Mentionable Select component.