Saltar a contenido

bostie.ui

bostie.ui

RawComponent module-attribute

RawComponent = NewType('RawComponent', dict[str, Any])

InteractiveStyle

InteractiveStyle = Literal[PRIMARY, SECONDARY, SUCCESS, DANGER]

ButtonStyle

Bases: DiscordIntEnum

PRIMARY class-attribute instance-attribute

PRIMARY = 1

SECONDARY class-attribute instance-attribute

SECONDARY = 2

SUCCESS class-attribute instance-attribute

SUCCESS = 3

DANGER class-attribute instance-attribute

DANGER = 4
LINK = 5

PREMIUM class-attribute instance-attribute

PREMIUM = 6

TextInputStyle

Bases: DiscordIntEnum

SHORT class-attribute instance-attribute

SHORT = 1

PARAGRAPH class-attribute instance-attribute

PARAGRAPH = 2

ButtonDict

Bases: TypedDict

type instance-attribute

type: Literal[BUTTON]

id instance-attribute

style instance-attribute

style: ButtonStyle

label instance-attribute

label: NotRequired[str]

emoji instance-attribute

custom_id instance-attribute

custom_id: NotRequired[str]

sku_id instance-attribute

sku_id: NotRequired[int]

url instance-attribute

disabled instance-attribute

disabled: bool

SelectOptionDict

Bases: TypedDict

label instance-attribute

label: str

value instance-attribute

value: str

description instance-attribute

description: NotRequired[str]

emoji instance-attribute

default instance-attribute

default: bool

StringSelectDict

Bases: TypedDict

type instance-attribute

id instance-attribute

custom_id instance-attribute

custom_id: str

options instance-attribute

placeholder instance-attribute

placeholder: NotRequired[str]

min_values instance-attribute

min_values: int

max_values instance-attribute

max_values: int

required instance-attribute

required: NotRequired[bool]

disabled instance-attribute

disabled: bool

SelectDefaultDict

Bases: TypedDict

id instance-attribute

id: int

type instance-attribute

EntitySelectDict

Bases: TypedDict

type instance-attribute

type: _EntitySelectType

id instance-attribute

custom_id instance-attribute

custom_id: str

channel_types instance-attribute

channel_types: NotRequired[list[ChannelType]]

placeholder instance-attribute

placeholder: NotRequired[str]

default_values instance-attribute

default_values: list[SelectDefaultDict]

min_values instance-attribute

min_values: int

max_values instance-attribute

max_values: int

required instance-attribute

required: NotRequired[bool]

disabled instance-attribute

disabled: bool

RowDict

Bases: TypedDict

type instance-attribute

id instance-attribute

components instance-attribute

components: list[_RowChild]

TextDict

Bases: TypedDict

type instance-attribute

id instance-attribute

content instance-attribute

content: str

ThumbnailDict

Bases: TypedDict

type instance-attribute

id instance-attribute

media instance-attribute

media: dict[str, str]

description instance-attribute

description: NotRequired[str]

spoiler instance-attribute

spoiler: bool

SectionDict

Bases: TypedDict

type instance-attribute

id instance-attribute

components instance-attribute

components: list[TextDict | RawComponent]

accessory instance-attribute

GalleryItemDict

Bases: TypedDict

media instance-attribute

media: dict[str, str]

description instance-attribute

description: NotRequired[str]

spoiler instance-attribute

spoiler: bool

MediaGalleryDict

Bases: TypedDict

type instance-attribute

id instance-attribute

items instance-attribute

FileDict

Bases: TypedDict

type instance-attribute

type: Literal[FILE]

id instance-attribute

file instance-attribute

file: dict[str, str]

spoiler instance-attribute

spoiler: bool

SeparatorDict

Bases: TypedDict

type instance-attribute

id instance-attribute

divider instance-attribute

divider: bool

spacing instance-attribute

spacing: Literal[1, 2]

ContainerDict

Bases: TypedDict

type instance-attribute

id instance-attribute

components instance-attribute

components: list[_ContainerChild]

accent_color instance-attribute

accent_color: NotRequired[int]

spoiler instance-attribute

spoiler: bool

TextInputDict

Bases: TypedDict

type instance-attribute

id instance-attribute

custom_id instance-attribute

custom_id: str

style instance-attribute

min_length instance-attribute

min_length: NotRequired[int]

max_length instance-attribute

max_length: NotRequired[int]

required instance-attribute

required: bool

value instance-attribute

value: NotRequired[str]

placeholder instance-attribute

placeholder: NotRequired[str]

FileUploadDict

Bases: TypedDict

type instance-attribute

id instance-attribute

custom_id instance-attribute

custom_id: str

min_values instance-attribute

min_values: int

max_values instance-attribute

max_values: int

required instance-attribute

required: bool

file_types instance-attribute

file_types: NotRequired[list[str]]

GroupOptionDict

Bases: TypedDict

value instance-attribute

value: str

label instance-attribute

label: str

description instance-attribute

description: NotRequired[str]

default instance-attribute

default: bool

RadioGroupDict

Bases: TypedDict

type instance-attribute

id instance-attribute

custom_id instance-attribute

custom_id: str

options instance-attribute

required instance-attribute

required: bool

CheckboxGroupDict

Bases: TypedDict

type instance-attribute

id instance-attribute

custom_id instance-attribute

custom_id: str

options instance-attribute

min_values instance-attribute

min_values: int

max_values instance-attribute

max_values: NotRequired[int]

required instance-attribute

required: bool

CheckboxDict

Bases: TypedDict

type instance-attribute

id instance-attribute

custom_id instance-attribute

custom_id: str

default instance-attribute

default: bool

LabelDict

Bases: TypedDict

type instance-attribute

type: Literal[LABEL]

id instance-attribute

label instance-attribute

label: str

description instance-attribute

description: NotRequired[str]

component instance-attribute

component: _LabelChild

ModalDict

Bases: TypedDict

custom_id instance-attribute

custom_id: str

title instance-attribute

title: str

components instance-attribute

components: list[_ModalChild]

raw

raw(component: Mapping[str, Any]) -> RawComponent

A component ui has no builder for, sent as given.

row

row(*components: _RowChild, id: int | None = None) -> RowDict

An action row holding up to five buttons or one select menu.

button

button(label: str | None, *, custom_id: str, style: InteractiveStyle = SECONDARY, emoji: AnyEmoji | None = None, disabled: bool = False, id: int | None = None) -> ButtonDict

A button that sends custom_id to the bot when clicked.

pager

pager(route: ComponentRoute[...], page: int, count: int, **params: str | int) -> RowDict

Previous and next buttons around "page / count" for a {page:int} route.

Each button's custom_id is route.id(page=..., **params), so pages survive a restart; the first page is 0.

link_button(label: str | None, url: str, *, emoji: AnyEmoji | None = None, disabled: bool = False, id: int | None = None) -> ButtonDict

A button that opens url and never reaches the bot.

premium_button

premium_button(sku_id: int, *, disabled: bool = False, id: int | None = None) -> ButtonDict

A button that offers the SKU sku_id for sale and never reaches the bot.

string_select

string_select(custom_id: str, options: Iterable[SelectOptionDict], *, placeholder: str | None = None, min_values: int = 1, max_values: int = 1, required: bool = True, disabled: bool = False, id: int | None = None) -> StringSelectDict

A select menu of fixed options; build them with select_option.

user_select

user_select(custom_id: str, *, defaults: Iterable[int] = (), placeholder: str | None = None, min_values: int = 1, max_values: int = 1, required: bool = True, disabled: bool = False, id: int | None = None) -> EntitySelectDict

A select menu of users; defaults are the ids of users shown as chosen.

role_select

role_select(custom_id: str, *, defaults: Iterable[int] = (), placeholder: str | None = None, min_values: int = 1, max_values: int = 1, required: bool = True, disabled: bool = False, id: int | None = None) -> EntitySelectDict

A select menu of roles; defaults are the ids of roles shown as chosen.

mentionable_select

mentionable_select(custom_id: str, *, default_users: Iterable[int] = (), default_roles: Iterable[int] = (), placeholder: str | None = None, min_values: int = 1, max_values: int = 1, required: bool = True, disabled: bool = False, id: int | None = None) -> EntitySelectDict

A select menu of users and roles, with these ids shown as chosen.

channel_select

channel_select(custom_id: str, *, channel_types: Iterable[ChannelType] = (), defaults: Iterable[int] = (), placeholder: str | None = None, min_values: int = 1, max_values: int = 1, required: bool = True, disabled: bool = False, id: int | None = None) -> EntitySelectDict

A select menu of channels, of channel_types only when given.

select_option

select_option(label: str, value: str, *, description: str | None = None, emoji: AnyEmoji | None = None, default: bool = False) -> SelectOptionDict

One entry of a select menu; value is what the bot receives.

text

text(content: str, *, id: int | None = None) -> TextDict

Markdown text; Components V2 messages use it instead of content.

section

section(*texts: TextDict | RawComponent, accessory: ButtonDict | ThumbnailDict | RawComponent, id: int | None = None) -> SectionDict

One to three text components with a button or thumbnail beside them.

thumbnail

thumbnail(url: str, *, description: str | None = None, spoiler: bool = False, id: int | None = None) -> ThumbnailDict

A small image for a section; url may be attachment://<filename>.

media_gallery(*items: GalleryItemDict | RawComponent, id: int | None = None) -> MediaGalleryDict

One to ten images or videos built with gallery_item.

gallery_item

gallery_item(url: str, *, description: str | None = None, spoiler: bool = False) -> GalleryItemDict

One entry of a media_gallery; url may be attachment://<filename>.

file

file(filename: str, *, spoiler: bool = False, id: int | None = None) -> FileDict

A file uploaded with the message, named as in its File.

separator

separator(*, divider: bool = True, spacing: Literal[1, 2] = 1, id: int | None = None) -> SeparatorDict

Space between components; spacing=2 is large, and divider draws a line.

container

container(*components: _ContainerChild, accent_color: int | None = None, spoiler: bool = False, id: int | None = None) -> ContainerDict

A box around rows, texts, sections, galleries, files and separators.

modal

modal(custom_id: str, title: str, *components: _ModalChild) -> ModalDict

A popup form of one to five label and text components.

label

label(label: str, component: _LabelChild, *, description: str | None = None, id: int | None = None) -> LabelDict

A modal field: label and description over one input, select or upload.

text_input

text_input(custom_id: str, *, style: TextInputStyle = SHORT, placeholder: str | None = None, value: str | None = None, min_length: int | None = None, max_length: int | None = None, required: bool = True, id: int | None = None) -> TextInputDict

A text box in a label; value fills it in beforehand.

file_upload

file_upload(custom_id: str, *, min_values: int = 1, max_values: int = 1, required: bool = True, file_types: Iterable[str] = (), id: int | None = None) -> FileUploadDict

Up to ten files uploaded in a label; file_types such as "image" or ".pdf".

radio_group

radio_group(custom_id: str, options: Iterable[GroupOptionDict], *, required: bool = True, id: int | None = None) -> RadioGroupDict

Two to ten options in a label, of which one is picked.

checkbox_group

checkbox_group(custom_id: str, options: Iterable[GroupOptionDict], *, min_values: int = 1, max_values: int | None = None, required: bool = True, id: int | None = None) -> CheckboxGroupDict

Checkboxes in a label; without max_values all of them can be ticked.

group_option

group_option(label: str, value: str, *, description: str | None = None, default: bool = False) -> GroupOptionDict

One entry of a radio_group or checkbox_group.

checkbox

checkbox(custom_id: str, *, default: bool = False, id: int | None = None) -> CheckboxDict

A single yes or no box in a label.