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=(ComponentV2Types.CONTAINER))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.CONTAINER for this class. See ComponentV2Types.
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=(ComponentV2Types.SECTION))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.SECTION for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
TextDisplay
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=(ComponentV2Types.TEXT_DISPLAY))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.TEXT_DISPLAY for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
Thumbnail
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).
type: int = field(init=False, default=(ComponentV2Types.THUMBNAIL))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.THUMBNAIL for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
MediaGallery
dataclass
¶
Bases: DataModel, ContainerChild
Represents the Media Gallery component.
items: list[MediaGalleryItem] = field(default_factory=list)
class-attribute
instance-attribute
¶
1 to 10 nedia gallery items. See MediaGalleryItem.
type: int = field(init=False, default=(ComponentV2Types.MEDIA_GALLERY))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.MEDIA_GALLERY for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
MediaGalleryItem
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).
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
File
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).
type: int = field(init=False, default=(ComponentV2Types.FILE))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.File for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
Separator
dataclass
¶
Bases: DataModel, ContainerChild
Represents the Separator component.
divider: 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 SMALL_PADDING. See SeparatorTypes.
type: int = field(init=False, default=(ComponentV2Types.SEPARATOR))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.SEPARATOR for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
SeparatorTypes
¶
Label
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=(ComponentV2Types.LABEL))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.LABEL for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss
FileUpload
dataclass
¶
Bases: DataModel, ContainerChild
Represents the file upload component.
component: LabelChild = 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.
type: int = field(init=False, default=(ComponentV2Types.FILE_UPLOAD))
class-attribute
instance-attribute
¶
Component type. Always ComponentV2Types.FILE_UPLOAD for this class. See ComponentV2Types.
to_dict
¶
Recursively turns the dataclass into a dictionary and drops empty fields.
Returns:
-
dict–serialized dataclasss