Components

This section documents everything related to message components — a 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 versions, see Bot UI Kit.

Discord Models

Component

Attributes
class disnake.Component[source]

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]

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.

children

The children components that this holds, if any.

Type:

List[Union[Button, BaseSelectMenu, TextInput]]

Button

class disnake.Button[source]

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[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

ChannelSelectMenu

class disnake.ChannelSelectMenu[source]

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

Note

The user constructible and usable type to create a channel select menu is disnake.ui.ChannelSelect.

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

disabled

Whether the select menu is disabled or not.

Type:

bool

channel_types

A list of channel types that can be selected in this select menu. If None, channels of all types may be selected.

Type:

Optional[List[ChannelType]]

MentionableSelectMenu

class disnake.MentionableSelectMenu[source]

Represents a mentionable (user/member/role) select menu from the Discord Bot UI Kit.

Note

The user constructible and usable type to create a mentionable select menu is disnake.ui.MentionableSelect.

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

disabled

Whether the select menu is disabled or not.

Type:

bool

RoleSelectMenu

class disnake.RoleSelectMenu[source]

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

Note

The user constructible and usable type to create a role select menu is disnake.ui.RoleSelect.

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

disabled

Whether the select menu is disabled or not.

Type:

bool

StringSelectMenu

class disnake.StringSelectMenu[source]

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

New in version 2.0.

Changed in version 2.7: Renamed from SelectMenu to StringSelectMenu.

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]

UserSelectMenu

class disnake.UserSelectMenu[source]

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

Note

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

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

disabled

Whether the select menu is disabled or not.

Type:

bool

TextInput

class disnake.TextInput[source]

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]

Data Classes

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

Enumerations

ComponentType

class disnake.ComponentType[source]

Represents the type of component.

New in version 2.0.

action_row

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

button

Represents a button component.

string_select

Represents a string select component.

New in version 2.7.

select

An alias of string_select.

text_input

Represents a text input component.

user_select

Represents a user select component.

New in version 2.7.

role_select

Represents a role select component.

New in version 2.7.

mentionable_select

Represents a mentionable (user/member/role) select component.

New in version 2.7.

channel_select

Represents a channel select component.

New in version 2.7.

ButtonStyle

class disnake.ButtonStyle[source]

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]

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.