Components

This section documents everything related to message components - Discord feature which allows bot developers to create their own component-based UIs right inside Discord.

Warning

Classes listed below are not meant to be created by user and are only recieved from the API. For constructible version see Bot UI Kit.

Discord Models

Component

Attributes
class disnake.Component[source]

This class is a Discord Model.

Represents a Discord Bot UI Kit Component.

Currently, the only components supported by Discord are:

This class is abstract and cannot be instantiated.

New in version 2.0.

type

The type of component.

Type:

ComponentType

ActionRow

Attributes
class disnake.ActionRow[source]

This class is a Discord Model.

Represents an action row.

This is a component that holds up to 5 children components in a row.

This inherits from Component.

New in version 2.0.

type

The type of component.

Type:

ComponentType

children

The children components that this holds, if any.

Type:

List[Union[Button, BaseSelectMenu, TextInput]]

Button

class disnake.Button[source]

This class is a Discord Model.

Represents a button from the Discord Bot UI Kit.

This inherits from Component.

Note

The user constructible and usable type to create a button is disnake.ui.Button, not this one.

New in version 2.0.

style

The style of the button.

Type:

ButtonStyle

custom_id

The ID of the button that gets received during an interaction. If this button is for a URL, it does not have a custom ID.

Type:

Optional[str]

url

The URL this button sends you to.

Type:

Optional[str]

disabled

Whether the button is disabled or not.

Type:

bool

label

The label of the button, if any.

Type:

Optional[str]

emoji

The emoji of the button, if available.

Type:

Optional[PartialEmoji]

BaseSelectMenu

class disnake.BaseSelectMenu(data)[source]

Represents an abstract select menu from the Discord Bot UI Kit.

A select menu is functionally the same as a dropdown, however on mobile it renders a bit differently.

The currently supported select menus are:

New in version 2.7.

custom_id

The ID of the select menu that gets received during an interaction.

Type:

Optional[str]

placeholder

The placeholder text that is shown if nothing is selected, if any.

Type:

Optional[str]

min_values

The minimum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.

Type:

int

options

A list of options that can be selected in this select menu.

Type:

List[SelectOption]

disabled

Whether the select menu is disabled or not.

Type:

bool

SelectMenu

class disnake.SelectMenu[source]

This class is a Discord Model.

Represents a string select menu from the Discord Bot UI Kit.

Note

The user constructible and usable type to create a string select menu is disnake.ui.Select.

New in version 2.0.

custom_id

The ID of the select menu that gets received during an interaction.

Type:

Optional[str]

placeholder

The placeholder text that is shown if nothing is selected, if any.

Type:

Optional[str]

min_values

The minimum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.

Type:

int

disabled

Whether the select menu is disabled or not.

Type:

bool

options

A list of options that can be selected in this select menu.

Type:

List[SelectOption]

SelectOption

class disnake.SelectOption(*, label, value=..., description=None, emoji=None, default=False)[source]

Represents a string select menu’s option.

These can be created by users.

New in version 2.0.

label

The label of the option. This is displayed to users. Can only be up to 100 characters.

Type:

str

value

The value of the option. This is not displayed to users. If not provided when constructed then it defaults to the label. Can only be up to 100 characters.

Type:

str

description

An additional description of the option, if any. Can only be up to 100 characters.

Type:

Optional[str]

emoji

The emoji of the option, if available.

Type:

Optional[Union[str, Emoji, PartialEmoji]]

default

Whether this option is selected by default.

Type:

bool

TextInput

class disnake.TextInput[source]

This class is a Discord Model.

Represents a text input from the Discord Bot UI Kit.

New in version 2.4.

Note

The user constructible and usable type to create a text input is disnake.ui.TextInput, not this one.

style

The style of the text input.

Type:

TextInputStyle

label

The label of the text input.

Type:

Optional[str]

custom_id

The ID of the text input that gets received during an interaction.

Type:

str

placeholder

The placeholder text that is shown if nothing is entered.

Type:

Optional[str]

value

The pre-filled text of the text input.

Type:

Optional[str]

required

Whether the text input is required. Defaults to True.

Type:

bool

min_length

The minimum length of the text input.

Type:

Optional[int]

max_length

The maximum length of the text input.

Type:

Optional[int]

Enumerations

ComponentType

class disnake.ComponentType[source]

This class is an Enumeration.

Represents the component type of a component.

New in version 2.0.

action_row

Represents the group component which holds different components in a row.

button

Represents a button component.

select

Represents a select component.

text_input

Represents a text input component.

ButtonStyle

class disnake.ButtonStyle[source]

This class is an Enumeration.

Represents the style of the button component.

New in version 2.0.

primary

Represents a blurple button for the primary action.

secondary

Represents a grey button for the secondary action.

success

Represents a green button for a successful action.

danger

Represents a red button for a dangerous action.

Represents a link button.

blurple

An alias for primary.

grey

An alias for secondary.

gray

An alias for secondary.

green

An alias for success.

red

An alias for danger.

url

An alias for link.

TextInputStyle

class disnake.TextInputStyle[source]

This class is an Enumeration.

Represents a style of the text input component.

New in version 2.4.

short

Represents a single-line text input component.

paragraph

Represents a multi-line text input component.

single_line

An alias for short.

multi_line

An alias for paragraph.

long

An alias for paragraph.