Skip to content

Components API

Note

The following classes come from the scurrypy.parts.components module.


ActionRowPart dataclass

Bases: DataModel, ContainerChild

Represents a container of interactable components.

components: list[ActionRowChild] = field(default_factory=list) class-attribute instance-attribute

Up to 5 interactive button components or a single select component.

type: int = field(init=False, default=(ComponentTypes.ACTION_ROW)) class-attribute instance-attribute

Component type. Always ComponentTypes.ACTION_ROW for this class. See ComponentTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


Button dataclass

Bases: DataModel, ActionRowChild, SectionAccessoryChild

Represents the Button component.

style: int = None class-attribute instance-attribute

A button style. See ButtonStyles.

custom_id: str = None class-attribute instance-attribute

ID for the button. Do not supply for LINK style buttons.

label: Optional[str] = None class-attribute instance-attribute

Text that appears on the button.

emoji: EmojiModel = None class-attribute instance-attribute

Emoji icon as emoji string or EmojiModel if custom.

url: Optional[str] = None class-attribute instance-attribute

URL for link-style buttons.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether the button is disabled. Defaults to False.

Hyperlink for button. For LINK style only.

type: int = field(init=False, default=(ComponentTypes.BUTTON)) class-attribute instance-attribute

Component type. Always ComponentTypes.BUTTON for this class. See ComponentTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

ButtonStyles

Represents button styles for a Button component.

PRIMARY = 1 class-attribute instance-attribute

The most important or recommended action in a group of options. (Blurple)

SECONDARY = 2 class-attribute instance-attribute

Alternative or supporting actions. (Gray)

SUCCESS = 3 class-attribute instance-attribute

Positive confirmation or completion actions. (Green)

DANGER = 4 class-attribute instance-attribute

An action with irreversible consequences. (Red)

Navigates to a URL. (Gray + window)


StringSelect dataclass

Bases: DataModel, ActionRowChild, LabelChild

Represents the String Select component.

custom_id: str = None class-attribute instance-attribute

ID for the select menu.

options: list[SelectOption] = field(default_factory=list) class-attribute instance-attribute

Specified choices in a select menu. See SelectOption.

placeholder: Optional[str] = None class-attribute instance-attribute

Placeholder text if nothing is selected or default.

min_values: Optional[int] = 1 class-attribute instance-attribute

Minimum number of items that must be chosen.

max_values: Optional[int] = 1 class-attribute instance-attribute

Maximum number of items that can be chosen.

required: Optional[bool] = False class-attribute instance-attribute

Whether the string select is required to answer in a modal. Defaults to False.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether select menu is disabled in a message. Defaults to False.

type: int = field(init=False, default=(ComponentTypes.STRING_SELECT)) class-attribute instance-attribute

Component type. Always ComponentTypes.STRING_SELECT for this class. See ComponentTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

SelectOption dataclass

Bases: DataModel

Represents the Select Option component

label: str = None class-attribute instance-attribute

User-facing name of the option.

value: str = None class-attribute instance-attribute

Developer-defined value of the option.

description: Optional[str] = None class-attribute instance-attribute

Additional description of the option.

emoji: Optional[EmojiModel] = None class-attribute instance-attribute

Partial emoji object.

default: Optional[bool] = False class-attribute instance-attribute

Whether this option is selected by default.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


TextInput dataclass

Bases: DataModel, LabelChild

Represents the Text Input component.

custom_id: str = None class-attribute instance-attribute

ID for the input.

style: TextInputStyles = TextInputStyles.SHORT class-attribute instance-attribute

Text input style. See TextInputStyles.

min_length: Optional[int] = None class-attribute instance-attribute

Minimum input length for a text input.

max_length: Optional[int] = None class-attribute instance-attribute

Maximum input length for a text input.

required: Optional[bool] = True class-attribute instance-attribute

Whether this component is required to be filled. Defaults to True.

value: Optional[str] = None class-attribute instance-attribute

Pre-filled value for this component.

placeholder: Optional[str] = None class-attribute instance-attribute

Custom placeholder text if the input is empty.

type: int = field(init=False, default=(ComponentTypes.TEXT_INPUT)) class-attribute instance-attribute

Component type. Always ComponentTypes.TEXT_INPUT for this class. See ComponentTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

TextInputStyles

Represents the types of Text Inputs.

SHORT = 1 class-attribute instance-attribute

One line text input.

PARAGRAPH = 2 class-attribute instance-attribute

Multi-line text input.


UserSelect dataclass

Bases: SelectMenu, ActionRowChild, LabelChild

Represents the User Select component.

type: int = field(init=False, default=(ComponentTypes.USER_SELECT)) class-attribute instance-attribute

Component type. Always ComponentTypes.USER_SELECT for this class. See ComponentTypes.

custom_id: str = None class-attribute instance-attribute

ID for the select menu.

placeholder: Optional[str] = None class-attribute instance-attribute

Placeholder text if nothing is selected.

default_values: Optional[list[DefaultValue]] = field(default_factory=list) class-attribute instance-attribute

List of default values for auto-populated select menu components. See DefaultValue. Number of default values must be in the range of min_values to max_values.

min_values: Optional[int] = 1 class-attribute instance-attribute

Minimum number of items that must be chosen. Defaults to 1.

max_values: Optional[int] = 1 class-attribute instance-attribute

Maximum number of items that can be chosen. Defaults to 1.

required: Optional[bool] = False class-attribute instance-attribute

Whether the select is required to answer in a modal. Defaults to False.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether select menu is disabled in a message. Defaults to False.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


RoleSelect dataclass

Bases: SelectMenu, ActionRowChild, LabelChild

Represents the Role Select component.

type: int = field(init=False, default=(ComponentTypes.ROLE_SELECT)) class-attribute instance-attribute

Component type. Always ComponentTypes.ROLE_SELECT for this class. See ComponentTypes.

custom_id: str = None class-attribute instance-attribute

ID for the select menu.

placeholder: Optional[str] = None class-attribute instance-attribute

Placeholder text if nothing is selected.

default_values: Optional[list[DefaultValue]] = field(default_factory=list) class-attribute instance-attribute

List of default values for auto-populated select menu components. See DefaultValue. Number of default values must be in the range of min_values to max_values.

min_values: Optional[int] = 1 class-attribute instance-attribute

Minimum number of items that must be chosen. Defaults to 1.

max_values: Optional[int] = 1 class-attribute instance-attribute

Maximum number of items that can be chosen. Defaults to 1.

required: Optional[bool] = False class-attribute instance-attribute

Whether the select is required to answer in a modal. Defaults to False.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether select menu is disabled in a message. Defaults to False.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


MentionableSelect dataclass

Bases: SelectMenu, ActionRowChild, LabelChild

Represents the Mentionable Select component.

type: int = field(init=False, default=(ComponentTypes.MENTIONABLE_SELECT)) class-attribute instance-attribute

Component type. Always ComponentTypes.MENTIONABLE_SELECT for this class. See ComponentTypes.

custom_id: str = None class-attribute instance-attribute

ID for the select menu.

placeholder: Optional[str] = None class-attribute instance-attribute

Placeholder text if nothing is selected.

default_values: Optional[list[DefaultValue]] = field(default_factory=list) class-attribute instance-attribute

List of default values for auto-populated select menu components. See DefaultValue. Number of default values must be in the range of min_values to max_values.

min_values: Optional[int] = 1 class-attribute instance-attribute

Minimum number of items that must be chosen. Defaults to 1.

max_values: Optional[int] = 1 class-attribute instance-attribute

Maximum number of items that can be chosen. Defaults to 1.

required: Optional[bool] = False class-attribute instance-attribute

Whether the select is required to answer in a modal. Defaults to False.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether select menu is disabled in a message. Defaults to False.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


ChannelSelect dataclass

Bases: SelectMenu, ActionRowChild, LabelChild

Represents the Channel Select component.

type: int = field(init=False, default=(ComponentTypes.CHANNEL_SELECT)) class-attribute instance-attribute

Component type. Always ComponentTypes.CHANNEL_SELECT for this class. See ComponentTypes.

custom_id: str = None class-attribute instance-attribute

ID for the select menu.

placeholder: Optional[str] = None class-attribute instance-attribute

Placeholder text if nothing is selected.

default_values: Optional[list[DefaultValue]] = field(default_factory=list) class-attribute instance-attribute

List of default values for auto-populated select menu components. See DefaultValue. Number of default values must be in the range of min_values to max_values.

min_values: Optional[int] = 1 class-attribute instance-attribute

Minimum number of items that must be chosen. Defaults to 1.

max_values: Optional[int] = 1 class-attribute instance-attribute

Maximum number of items that can be chosen. Defaults to 1.

required: Optional[bool] = False class-attribute instance-attribute

Whether the select is required to answer in a modal. Defaults to False.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether select menu is disabled in a message. Defaults to False.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


DefaultValue dataclass

Bases: DataModel

Represents the Default Value for Select components.

id: int = None class-attribute instance-attribute

ID of role, user, or channel.

type: Literal['role', 'user', 'channel'] = None class-attribute instance-attribute

Type of value that id represents.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


SelectMenu dataclass

Bases: DataModel

Represents common fields for Discord's select menus.

custom_id: str = None class-attribute instance-attribute

ID for the select menu.

placeholder: Optional[str] = None class-attribute instance-attribute

Placeholder text if nothing is selected.

default_values: Optional[list[DefaultValue]] = field(default_factory=list) class-attribute instance-attribute

List of default values for auto-populated select menu components. See DefaultValue. Number of default values must be in the range of min_values to max_values.

min_values: Optional[int] = 1 class-attribute instance-attribute

Minimum number of items that must be chosen. Defaults to 1.

max_values: Optional[int] = 1 class-attribute instance-attribute

Maximum number of items that can be chosen. Defaults to 1.

required: Optional[bool] = False class-attribute instance-attribute

Whether the select is required to answer in a modal. Defaults to False.

disabled: Optional[bool] = False class-attribute instance-attribute

Whether select menu is disabled in a message. Defaults to False.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


ComponentTypes

ACTION_ROW = 1 class-attribute instance-attribute

BUTTON = 2 class-attribute instance-attribute

STRING_SELECT = 3 class-attribute instance-attribute

TEXT_INPUT = 4 class-attribute instance-attribute

USER_SELECT = 5 class-attribute instance-attribute

ROLE_SELECT = 6 class-attribute instance-attribute

MENTIONABLE_SELECT = 7 class-attribute instance-attribute

CHANNEL_SELECT = 8 class-attribute instance-attribute