hikari.components#
Application and entities that are used to describe components on Discord.
AllowedComponentsT module-attribute #
COMPONENT_V2_TYPES module-attribute #
COMPONENT_V2_TYPES: Final[frozenset[ComponentType]] = (
frozenset(
(
ComponentType.SECTION,
ComponentType.TEXT_DISPLAY,
ComponentType.THUMBNAIL,
ComponentType.MEDIA_GALLERY,
ComponentType.FILE,
ComponentType.SEPARATOR,
ComponentType.CONTAINER,
)
)
)
Set of the component types which are considered v2 components and can only be used with the appropriate flag.
The following values are included in this:
ContainerTypesT module-attribute #
ContainerTypesT = typing.Union[
ActionRowComponent[PartialComponent],
TextDisplayComponent,
SectionComponent,
MediaGalleryComponent,
SeparatorComponent,
FileComponent,
]
Type hints of the values which are valid for container components.
The following values are valid for this:
InteractiveButtonTypes module-attribute #
InteractiveButtonTypes: AbstractSet[
InteractiveButtonTypesT
] = frozenset(
[
ButtonStyle.PRIMARY,
ButtonStyle.SECONDARY,
ButtonStyle.SUCCESS,
ButtonStyle.DANGER,
]
)
Set of the hikari.components.ButtonStyle which are valid for interactive buttons.
The following values are included in this:
InteractiveButtonTypesT module-attribute #
InteractiveButtonTypesT = typing.Literal[
ButtonStyle.PRIMARY,
1,
ButtonStyle.SECONDARY,
2,
ButtonStyle.SUCCESS,
3,
ButtonStyle.DANGER,
4,
]
Type hints of the hikari.components.ButtonStyle values which are valid for interactive buttons.
The following values are valid for this:
MessageActionRowComponent module-attribute #
MessageActionRowComponent = ActionRowComponent[
MessageComponentTypesT
]
A message action row component.
MessageComponentTypesT module-attribute #
MessageComponentTypesT = typing.Union[
ButtonComponent, SelectMenuComponent
]
Type hint of the hikari.components.PartialComponent that be contained in a hikari.components.PartialComponent.
The following values are valid for this:
ModalActionRowComponent module-attribute #
ModalActionRowComponent = ActionRowComponent[
ModalComponentTypesT
]
A modal action row component.
ModalComponentTypesT module-attribute #
ModalComponentTypesT = TextInputComponent
Type hint of the hikari.components.PartialComponent that be contained in a hikari.components.PartialComponent.
The following values are valid for this:
SectionAccessoryTypesT module-attribute #
SectionAccessoryTypesT = typing.Union[
ButtonComponent, ThumbnailComponent
]
Type hints of the values which are valid for section accessories.
The following values are valid for this:
SectionComponentTypesT module-attribute #
SectionComponentTypesT = TextDisplayComponent
Type hints of the values which are valid for section components.
The following values are valid for this:
SelectMenuTypes module-attribute #
SelectMenuTypes: AbstractSet[SelectMenuTypesT] = frozenset(
(
ComponentType.TEXT_SELECT_MENU,
ComponentType.USER_SELECT_MENU,
ComponentType.ROLE_SELECT_MENU,
ComponentType.MENTIONABLE_SELECT_MENU,
ComponentType.CHANNEL_SELECT_MENU,
)
)
Set of the hikari.components.ComponentType values which are valid for select menus.
The following values are included in this:
SelectMenuTypesT module-attribute #
SelectMenuTypesT = typing.Literal[
ComponentType.TEXT_SELECT_MENU,
3,
ComponentType.USER_SELECT_MENU,
5,
ComponentType.ROLE_SELECT_MENU,
6,
ComponentType.MENTIONABLE_SELECT_MENU,
7,
ComponentType.CHANNEL_SELECT_MENU,
8,
]
Type hints of the hikari.components.ComponentType values which are valid for select menus.
The following values are valid for this:
TopLevelComponentTypesT module-attribute #
TopLevelComponentTypesT = typing.Union[
ActionRowComponent[PartialComponent],
TextDisplayComponent,
SectionComponent,
MediaGalleryComponent,
SeparatorComponent,
FileComponent,
ContainerComponent,
]
Type hints of the values which are valid for top level components.
The following values are valid for this:
ActionRowComponent #
Bases: PartialComponent, Generic[AllowedComponentsT]
Represents a row of components.
components class-attribute instance-attribute #
components: Sequence[AllowedComponentsT] = attrs.field()
Sequence of the components contained within this row.
ButtonComponent #
Bases: PartialComponent
Represents a button component.
custom_id class-attribute instance-attribute #
Developer defined identifier for this button (will be <= 100 characters).
Note
This is required for the following button styles:
emoji class-attribute instance-attribute #
Custom or unicode emoji which appears on the button.
is_disabled class-attribute instance-attribute #
Whether the button is disabled.
label class-attribute instance-attribute #
Text label which appears on the button.
style class-attribute instance-attribute #
style: ButtonStyle | int = attrs.field(eq=False)
The button's style.
url class-attribute instance-attribute #
Url for hikari.components.ButtonStyle.LINK style buttons.
ButtonStyle #
Bases: int, Enum
Enum of the available button styles.
More information, such as how these look, can be found at https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
DANGER class-attribute instance-attribute #
DANGER = 4
A red button (usually indicates a destructive action).
LINK class-attribute instance-attribute #
LINK = 5
A grey button which navigates to a URL.
Warning
Unlike the other button styles, clicking this one will not trigger an interaction and custom_id shouldn't be included for this style.
PREMIUM class-attribute instance-attribute #
PREMIUM = 6
A button that will link to a specific SKU item.
Warning
Unlike the other button styles, clicking this one will not trigger an interaction and custom_id shouldn't be included for this style.
ChannelSelectMenuComponent #
Bases: SelectMenuComponent
Represents a channel select menu component.
ComponentType #
Bases: int, Enum
Types of components found within Discord.
ACTION_ROW class-attribute instance-attribute #
ACTION_ROW = 1
A non-interactive container component for other types of components.
Note
As of writing this can only contain one component type.
BUTTON class-attribute instance-attribute #
BUTTON = 2
A button component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
CHANNEL_SELECT_MENU class-attribute instance-attribute #
CHANNEL_SELECT_MENU = 8
A channel select component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
CONTAINER class-attribute instance-attribute #
CONTAINER = 17
A container component.
Note
As this is a container component it can never be contained within another component and therefore will always be top-level.
MENTIONABLE_SELECT_MENU class-attribute instance-attribute #
MENTIONABLE_SELECT_MENU = 7
A mentionable (users and roles) select component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
ROLE_SELECT_MENU class-attribute instance-attribute #
ROLE_SELECT_MENU = 6
A role select component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
SECTION class-attribute instance-attribute #
SECTION = 9
A section component.
Note
As this is a container component it can never be contained within another component and therefore will always be top-level.
TEXT_INPUT class-attribute instance-attribute #
TEXT_INPUT = 4
A text input component.
Note
This component may only be used inside a modal container.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
TEXT_SELECT_MENU class-attribute instance-attribute #
TEXT_SELECT_MENU = 3
A text select component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
THUMBNAIL class-attribute instance-attribute #
THUMBNAIL = 11
A thumbnail component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.SECTION.
USER_SELECT_MENU class-attribute instance-attribute #
USER_SELECT_MENU = 5
A user select component.
Note
This cannot be top-level and must be within a container component such as hikari.components.ComponentType.ACTION_ROW.
ContainerComponent #
Bases: PartialComponent
Represents a container component.
FileComponent #
Bases: PartialComponent
Represents a file component.
MediaGalleryComponent #
Bases: PartialComponent
Represents a media gallery component.
items class-attribute instance-attribute #
items: Sequence[MediaGalleryItem] = attrs.field()
The media gallery's items.
MediaGalleryItem #
Represents a media gallery item.
MediaLoadingType #
MediaResource #
Bases: Resource[AsyncReader]
Represents a media resource.
content_type class-attribute instance-attribute #
content_type: UndefinedNoneOr[str] = attrs.field(repr=True)
The content type of the media item.
height class-attribute instance-attribute #
height: UndefinedNoneOr[int] = attrs.field(repr=True)
The height of the media item.
loading_state class-attribute instance-attribute #
loading_state: UndefinedNoneOr[MediaLoadingType] = (
attrs.field(repr=True)
)
The loading state of the media item.
proxy_filename property #
proxy_filename: str | None
File name of the proxied version of this embed resource if applicable, else None.
proxy_resource class-attribute instance-attribute #
proxy_resource: Resource[AsyncReader] | None = attrs.field(
default=None, repr=False
)
The proxied version of the resource, or None if not present.
Note
This field cannot be set by bots or webhooks while sending an embed and will be ignored during serialization. Expect this to be populated on any received embed attached to a message event.
proxy_url property #
proxy_url: str | None
Proxied URL of this embed resource if applicable, else None.
resource class-attribute instance-attribute #
resource: Resource[AsyncReader] = attrs.field(repr=True)
The resource this object wraps around.
width class-attribute instance-attribute #
width: UndefinedNoneOr[int] = attrs.field(repr=True)
The width of media item.
stream #
stream(
*,
executor: Executor | None = None,
head_only: bool = False,
) -> AsyncReaderContextManager[AsyncReader]
Produce a stream of data for the resource.
| PARAMETER | DESCRIPTION |
|---|---|
executor | The executor to run in for blocking operations. If TYPE: |
head_only | If TYPE: |
PartialComponent #
SectionComponent #
Bases: PartialComponent
Represents a section component.
accessory class-attribute instance-attribute #
accessory: SectionAccessoryTypesT = attrs.field()
The sections accessory.
components class-attribute instance-attribute #
components: Sequence[SectionComponentTypesT] = attrs.field()
The sections components.
SelectMenuComponent #
Bases: PartialComponent
Represents a select menu component.
custom_id class-attribute instance-attribute #
Developer defined identifier for this menu (will be <= 100 characters).
is_disabled class-attribute instance-attribute #
Whether the select menu is disabled.
max_values class-attribute instance-attribute #
The minimum amount of options which can be chosen for this menu.
This will be less than or equal to 25 and will be greater than or equal to hikari.components.SelectMenuComponent.min_values.
min_values class-attribute instance-attribute #
The minimum amount of options which must be chosen for this menu.
This will be greater than or equal to 0 and will be less than or equal to hikari.components.SelectMenuComponent.max_values.
SelectMenuOption #
Represents an option for a hikari.components.SelectMenuComponent.
description class-attribute instance-attribute #
Optional description of the option, max 100 characters.
emoji class-attribute instance-attribute #
Custom or unicode emoji which appears on the button.
is_default class-attribute instance-attribute #
Whether this option will be selected by default.
label class-attribute instance-attribute #
User-facing name of the option, max 100 characters.
SeparatorComponent #
Bases: PartialComponent
Represents the separator component.
SpacingType #
TextDisplayComponent #
Bases: PartialComponent
Represents a text display component.
TextInputComponent #
Bases: PartialComponent
Represents a text input component.
TextInputStyle #
TextSelectMenuComponent #
Bases: SelectMenuComponent
Represents a text select menu component.
options class-attribute instance-attribute #
options: Sequence[SelectMenuOption] = attrs.field(eq=False)
Sequence of up to 25 of the options set for this menu.
ThumbnailComponent #
Bases: PartialComponent
Represents a thumbnail component.