Skip to content

hikari.components#

Application and entities that are used to describe components on Discord.

InteractiveButtonTypes module-attribute #

InteractiveButtonTypesT module-attribute #

InteractiveButtonTypesT = Union[
    Literal[PRIMARY],
    Literal[1],
    Literal[SECONDARY],
    Literal[2],
    Literal[SUCCESS],
    Literal[3],
    Literal[DANGER],
    Literal[4],
]

MessageActionRowComponent module-attribute #

MessageActionRowComponent = ActionRowComponent[MessageComponentTypesT]

A message action row component.

MessageComponentTypesT module-attribute #

MessageComponentTypesT = Union[ButtonComponent, SelectMenuComponent]

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:

ActionRowComponent #

Bases: Generic[AllowedComponentsT], PartialComponent

Represents a row of components.

components class-attribute instance-attribute #

components: Sequence[AllowedComponentsT] = field()

Sequence of the components contained within this row.

type class-attribute instance-attribute #

The type of component this is.

ButtonComponent #

Bases: PartialComponent

Represents a button component.

custom_id class-attribute instance-attribute #

custom_id: Optional[str] = field(hash=True)

Developer defined identifier for this button (will be <= 100 characters).

emoji class-attribute instance-attribute #

emoji: Optional[Emoji] = field(eq=False)

Custom or unicode emoji which appears on the button.

is_disabled class-attribute instance-attribute #

is_disabled: bool = field(eq=False)

Whether the button is disabled.

label class-attribute instance-attribute #

label: Optional[str] = field(eq=False)

Text label which appears on the button.

style class-attribute instance-attribute #

style: Union[ButtonStyle, int] = field(eq=False)

The button's style.

type class-attribute instance-attribute #

The type of component this is.

url class-attribute instance-attribute #

url: Optional[str] = field(eq=False)

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 = 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.

PRIMARY class-attribute instance-attribute #

PRIMARY = 1

A blurple "call to action" button.

SECONDARY class-attribute instance-attribute #

SECONDARY = 2

A grey neutral button.

SUCCESS class-attribute instance-attribute #

SUCCESS = 3

A green button.

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.

ChannelSelectMenuComponent #

Bases: SelectMenuComponent

Represents a channel select menu component.

channel_types class-attribute instance-attribute #

channel_types: Sequence[Union[int, ChannelType]] = field(eq=False)

The valid channel types for this menu.

custom_id class-attribute instance-attribute #

custom_id: str = field(hash=True)

Developer defined identifier for this menu (will be <= 100 characters).

is_disabled class-attribute instance-attribute #

is_disabled: bool = field(eq=False)

Whether the select menu is disabled.

max_values class-attribute instance-attribute #

max_values: int = field(eq=False)

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 #

min_values: int = field(eq=False)

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.

placeholder class-attribute instance-attribute #

placeholder: Optional[str] = field(eq=False)

Custom placeholder text shown if nothing is selected, max 100 characters.

type class-attribute instance-attribute #

The type of component this is.

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 this is a container component it can never be contained within another component and therefore will always be top-level.

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.

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.

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.

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.

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.

PartialComponent #

Base class for all component entities.

type class-attribute instance-attribute #

The type of component this is.

SelectMenuComponent #

Bases: PartialComponent

Represents a select menu component.

custom_id class-attribute instance-attribute #

custom_id: str = field(hash=True)

Developer defined identifier for this menu (will be <= 100 characters).

is_disabled class-attribute instance-attribute #

is_disabled: bool = field(eq=False)

Whether the select menu is disabled.

max_values class-attribute instance-attribute #

max_values: int = field(eq=False)

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 #

min_values: int = field(eq=False)

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.

placeholder class-attribute instance-attribute #

placeholder: Optional[str] = field(eq=False)

Custom placeholder text shown if nothing is selected, max 100 characters.

type class-attribute instance-attribute #

The type of component this is.

SelectMenuOption #

Represents an option for a hikari.components.SelectMenuComponent.

description class-attribute instance-attribute #

description: Optional[str] = field()

Optional description of the option, max 100 characters.

emoji class-attribute instance-attribute #

emoji: Optional[Emoji] = field(eq=False)

Custom or unicode emoji which appears on the button.

is_default class-attribute instance-attribute #

is_default: bool = field()

Whether this option will be selected by default.

label class-attribute instance-attribute #

label: str = field()

User-facing name of the option, max 100 characters.

value class-attribute instance-attribute #

value: str = field()

Dev-defined value of the option, max 100 characters.

TextInputComponent #

Bases: PartialComponent

Represents a text input component.

custom_id class-attribute instance-attribute #

custom_id: str = field(repr=True)

Developer set custom ID used for identifying interactions with this modal.

type class-attribute instance-attribute #

The type of component this is.

value class-attribute instance-attribute #

value: str = field(repr=True)

Value provided for this text input.

TextInputStyle #

Bases: int, Enum

A text input style.

PARAGRAPH class-attribute instance-attribute #

PARAGRAPH = 2

Intended for much longer inputs.

SHORT class-attribute instance-attribute #

SHORT = 1

Intended for short single-line text.

name property #

name: str

Return the name of the enum member as a str.

value property #

value

Return the value of the enum member.

TextSelectMenuComponent #

Bases: SelectMenuComponent

Represents a text select menu component.

custom_id class-attribute instance-attribute #

custom_id: str = field(hash=True)

Developer defined identifier for this menu (will be <= 100 characters).

is_disabled class-attribute instance-attribute #

is_disabled: bool = field(eq=False)

Whether the select menu is disabled.

max_values class-attribute instance-attribute #

max_values: int = field(eq=False)

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 #

min_values: int = field(eq=False)

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.

options class-attribute instance-attribute #

options: Sequence[SelectMenuOption] = field(eq=False)

Sequence of up to 25 of the options set for this menu.

placeholder class-attribute instance-attribute #

placeholder: Optional[str] = field(eq=False)

Custom placeholder text shown if nothing is selected, max 100 characters.

type class-attribute instance-attribute #

The type of component this is.