UI Components API (COMPONENTS_V2)¶
Note
The following classes come from the scurrypy.parts.components_v2 module.
Important
Any message with Container components MUST HAVE the message flag IS_COMPONENTS_V2!
ContainerPart
dataclass
¶
Bases: DataModel
Represents a container of display and interactable components.
components: list[ContainerChild] = field(default_factory=list)
class-attribute
instance-attribute
¶
Child components that are encapsulated within the Container.
accent_color: Optional[int] = None
class-attribute
instance-attribute
¶
Color for the accent as an integer.
spoiler: Optional[bool] = False
class-attribute
instance-attribute
¶
If the container should be blurred out. Defaults to False.
type: int = field(init=False, default=(ComponentTypes.CONTAINER))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.CONTAINER for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
SectionPart
dataclass
¶
Bases: DataModel, ContainerChild
Represents the Section component.
accessory: SectionAccessoryChild = None
class-attribute
instance-attribute
¶
A component that is contextually associated to the content of the section.
components: list[SectionChild] = field(default_factory=list)
class-attribute
instance-attribute
¶
Component(s) representing the content of the section that is contextually associated to the accessory.
type: int = field(init=False, default=(ComponentTypes.SECTION))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.SECTION for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
TextDisplayPart
dataclass
¶
Bases: DataModel, ContainerChild, SectionChild
Represents the Text Display component.
content: str = None
class-attribute
instance-attribute
¶
Text that will be displayed similar to a message.
type: int = field(init=False, default=(ComponentTypes.TEXT_DISPLAY))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.TEXT_DISPLAY for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
ThumbnailPart
dataclass
¶
Bases: DataModel, SectionAccessoryChild
Represents the Thumbnail component.
media: str = None
class-attribute
instance-attribute
¶
Media of the thumbnail. http or attachment://
description: Optional[str] = None
class-attribute
instance-attribute
¶
Description for the media.
spoiler: Optional[bool] = False
class-attribute
instance-attribute
¶
Whether the thumbnail should be a spoiler (or blurred out). Defaults to False.
type: int = field(init=False, default=(ComponentTypes.THUMBNAIL))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.THUMBNAIL for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
MediaGalleryPart
dataclass
¶
Bases: DataModel, ContainerChild
Represents the Media Gallery component.
items: list[MediaGalleryItemPart] = field(default_factory=list)
class-attribute
instance-attribute
¶
1 to 10 nedia gallery items. See MediaGalleryItemPart.
type: int = field(init=False, default=(ComponentTypes.MEDIA_GALLERY))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.MEDIA_GALLERY for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
MediaGalleryItemPart
dataclass
¶
Bases: DataModel
Represents the Media Gallery Item component.
media: str = None
class-attribute
instance-attribute
¶
Image data. http or attachment://
description: Optional[str] = None
class-attribute
instance-attribute
¶
Alt text for the media.
spoiler: Optional[bool] = False
class-attribute
instance-attribute
¶
Whether the thumbnail should be a spoiler (or blurred out). Defaults to False.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
FilePart
dataclass
¶
Bases: DataModel, ContainerChild
Represents the File component.
file: str = None
class-attribute
instance-attribute
¶
File name. ONLY supports attachment://
spoiler: Optional[bool] = False
class-attribute
instance-attribute
¶
Whether the thumbnail should be a spoiler (or blurred out). Defaults to False.
type: int = field(init=False, default=(ComponentTypes.FILE))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.FILE for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
SeparatorPart
dataclass
¶
Bases: DataModel, ContainerChild
Represents the Separator component.
divider: Optional[bool] = True
class-attribute
instance-attribute
¶
Whether a visual divider should be displayed in the component. Defaults to True.
spacing: Optional[int] = SeparatorTypes.SMALL_PADDING
class-attribute
instance-attribute
¶
Size of separator padding. Defaults to SeparatorTypes.SMALL_PADDING. See SeparatorTypes.
type: int = field(init=False, default=(ComponentTypes.SEPARATOR))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.SEPARATOR for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
SeparatorTypes
¶
LabelPart
dataclass
¶
Bases: DataModel
Represents the Discord Label component.
label: str = None
class-attribute
instance-attribute
¶
Label text.
component: LabelChild = None
class-attribute
instance-attribute
¶
A component within the label.
description: Optional[str] = None
class-attribute
instance-attribute
¶
An optional description text for the label.
type: int = field(init=False, default=(ComponentTypes.LABEL))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.LABEL for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
FileUploadPart
dataclass
¶
Bases: DataModel, ContainerChild
Represents the file upload component.
custom_id: str = None
class-attribute
instance-attribute
¶
ID for the file upload.
min_values: Optional[int] = 1
class-attribute
instance-attribute
¶
Minimum number of items that must be uploaded.
max_values: Optional[int] = 1
class-attribute
instance-attribute
¶
Maximum number of items that can be uploaded.
required: Optional[bool] = True
class-attribute
instance-attribute
¶
Whether files are required to be uploaded. Defaults to True.
type: int = field(init=False, default=(ComponentTypes.FILE_UPLOAD))
class-attribute
instance-attribute
¶
Component type. Always ComponentTypes.FILE_UPLOAD for this class. See ComponentTypes.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss