Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
NeloBlivion authored Feb 6, 2025
1 parent 905b9ff commit 49080e7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
7 changes: 7 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,13 @@ class SubscriptionStatus(Enum):
inactive = 2


class SeparatorSpacingSize(Enum):
"""A separator component's spacing size."""

small = 1
large = 2


T = TypeVar("T")


Expand Down
59 changes: 32 additions & 27 deletions discord/types/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@
SeparatorSpacingSize = Literal[1, 2]


class ActionRow(TypedDict):
class BaseComponent(TypedDict):
type: ComponentType
id: NotRequired[int]


class ActionRow(BaseComponent):
type: Literal[1]
components: list[Component]


class ButtonComponent(TypedDict):
class ButtonComponent(BaseComponent):
custom_id: NotRequired[str]
url: NotRequired[str]
disabled: NotRequired[bool]
Expand All @@ -55,7 +60,7 @@ class ButtonComponent(TypedDict):
sku_id: Snowflake


class InputText(TypedDict):
class InputText(BaseComponent):
min_length: NotRequired[int]
max_length: NotRequired[int]
required: NotRequired[bool]
Expand All @@ -75,7 +80,7 @@ class SelectOption(TypedDict):
default: bool


class SelectMenu(TypedDict):
class SelectMenu(BaseComponent):
placeholder: NotRequired[str]
min_values: NotRequired[int]
max_values: NotRequired[int]
Expand All @@ -86,50 +91,60 @@ class SelectMenu(TypedDict):
custom_id: str


class TextDisplayComponent(TypedDict):
class TextDisplayComponent(BaseComponent):
type: Literal[10]
content: str


class UnfurledMediaItem:
class SectionComponent(BaseComponent):
type: Literal[9]
components: list[TextDisplayComponent, ButtonComponent]


class UnfurledMediaItem(TypedDict):
url: str


class MediaGalleryItem(TypedDict):
class ThumbnailComponent(BaseComponent):
type: Literal[11]
media: UnfurledMediaItem
description: NotRequired[str]
spoiler: NotRequired[bool]


class SectionComponent(TypedDict):
type: Literal[9]
components: list[TextDisplayComponent, ButtonComponent]


class ThumbnailComponent(TypedDict):
type: Literal[11]
class MediaGalleryItem(TypedDict):
media: UnfurledMediaItem
description: NotRequired[str]
spoiler: NotRequired[bool]


class MediaGalleryComponent(TypedDict):
class MediaGalleryComponent(BaseComponent):
type: Literal[12]
items: list[MediaGalleryItem]


class FileComponent(TypedDict):
class FileComponent(BaseComponent):
type: Literal[13]
file: UnfurledMediaItem
spoiler: NotRequired[bool]


class SeparatorComponent(TypedDict):
class SeparatorComponent(BaseComponent):
type: Literal[14]
divider: NotRequired[bool]
spacing: NotRequired[SeparatorSpacingSize]


class ContainerComponent(BaseComponent):
type: Literal[17]
accent_color: NotRequired[int]
spoiler: NotRequired[bool]
components: list[ContainerComponents]


Component = Union[ActionRow, ButtonComponent, SelectMenu, InputText]


ContainerComponents = Union[
ActionRow,
TextDisplayComponent,
Expand All @@ -138,13 +153,3 @@ class SeparatorComponent(TypedDict):
SeparatorComponent,
SectionComponent,
]


class ContainerComponent(TypedDict):
type: Literal[17]
accent_color: NotRequired[int]
spoiler: NotRequired[bool]
components: list[ContainerComponents]


Component = Union[ActionRow, ButtonComponent, SelectMenu, InputText]

0 comments on commit 49080e7

Please sign in to comment.