Componyents

This section documents evewything wewated t-to message componyents — a Discowd featuwe which awwows bot devewopews to cweate theiw own componyent-based UIs wight i-i-inside Discowd.

Wawnying

Cwasses wisted bewow awe nyot meant to be cweated b-by usew and awe onwy wecieved fwom t-the API. Fow constwuctibwe vewsions, see Bot UI Kit.

Discowd Modews

Componyent

Attwibutes
class disnake.Component[source]

Wepwesents the base componyent that aww othew componyents inhewit fwom.

The componyents suppowted b-b-by Discowd awe:

This cwass is abstwact and cannyot be instantiated.

Nyew i-i-in vewsion 2.0.

type

The type of componyent.

Type:

ComponentType

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message. If set to 0 (the defauwt) when sending a componyent, the API wiww assign sequentiaw identifiews to the componyents in the message.

Nyew in vewsion 2.11.

Type:

int

ActionWow

Attwibutes
class disnake.ActionRow[source]

Wepwesents an action wow.

T-This is a componyent that howds up to 5 chiwdwen componyents in a wow.

This inhewits fwom Component.

Nyew in vewsion 2.0.

children

The chiwdwen componyents that this howds, if any.

Type:

Wist[Unyion[Button, BaseSelectMenu, TextInput]]

id

T-The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

Button

class disnake.Button[source]

Wepwesents a button fwom the Discowd Bot UI Kit.

This inhewits fwom Component.

Nyote

The usew constwuctibwe and usabwe type to cweate a button is disnake.ui.Button, nyot this onye.

Nyew in vewsion 2.0.

style

The stywe of the button.

Type:

ButtonStyle

custom_id

The ID of the button that gets weceived duwing an intewaction. If this button is fow a UWW ow an SKU, it does nyot have a custom ID.

Type:

Optionyaw[str]

url

The UWW this button sends you to.

Type:

Optionyaw[str]

disabled

Whethew the button is disabwed ow nyot.

Type:

bool

label

The wabew of the button, if any.

Type:

Optionyaw[str]

emoji

The emoji of the button, if avaiwabwe.

Type:

O-Optionyaw[PartialEmoji]

sku_id

The ID of a puwchasabwe SKU, fow pwemium buttons. Pwemium buttons additionyawwy cannyot have a label, url, ow emoji.

Nyew in vewsion 2.11.

T-T-Type:

Optionyaw[int]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in v-vewsion 2.11.

T-Type:

int

BaseSewectMenyu

class disnake.BaseSelectMenu[source]

Wepwesents an abstwact sewect menyu fwom the Discowd Bot UI Kit.

A sewect menyu is functionyawwy the same as a dwopdown, howevew on mobiwe it wendews a bit diffewentwy.

The cuwwentwy suppowted sewect menyus awe:

Nyew in v-v-vewsion 2.7.

custom_id

T-T-The ID of the sewect menyu that g-g-gets weceived duwing an intewaction.

Type:

Optionyaw[str]

placeholder

The pwacehowdew text that is shown i-if nyothing is sewected, if any.

Type:

Optionyaw[str]

min_values

The m-m-minyimum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

options

A wist of options that can be sewected in this sewect menyu.

Type:

Wist[SelectOption]

disabled

Whethew the sewect menyu is disabwed ow nyot.

Type:

bool

default_values

The wist of vawues (usews/wowes/channyews) that awe sewected by defauwt. If set, the nyumbew of items must be within the bounds set by min_values and max_values. Onwy avaiwabwe fow auto-popuwated sewect menyus.

Nyew in vewsion 2.10.

Type:

Wist[SelectDefaultValue]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

C-C-ChannyewSewectMenyu

class disnake.ChannelSelectMenu[source]

Wepwesents a channyew sewect menyu fwom the D-Discowd Bot U-U-UI Kit.

Nyote

The usew constwuctibwe and usabwe type to cweate a channyew sewect menyu is disnake.ui.ChannelSelect.

Nyew in vewsion 2.7.

custom_id

The ID of the sewect menyu that gets weceived duwing an intewaction.

Type:

Optionyaw[str]

placeholder

The pwacehowdew text that is shown i-i-if nyothing is sewected, if any.

Type:

Optionyaw[str]

min_values

The minyimum nyumbew o-o-of i-items t-t-that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 a-a-and 25.

Type:

int

disabled

Whethew the sewect menyu is disabwed ow nyot.

Type:

bool

channel_types

A wist of channyew t-t-types that c-c-can be s-s-sewected i-in this sewect menyu. If None, channyews of aww types may be sewected.

Type:

Optionyaw[Wist[ChannelType]]

default_values

The wist of vawues (channyews) that awe sewected by defauwt. If set, t-t-the nyumbew of items must be within the bounds s-s-set by min_values and max_values.

Nyew in vewsion 2.10.

Type:

Wist[SelectDefaultValue]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

MentionyabweSewectMenyu

class disnake.MentionableSelectMenu[source]

Wepwesents a mentionyabwe (usew/membew/wowe) sewect menyu fwom the Discowd Bot UI Kit.

Nyote

The usew constwuctibwe and usabwe type to cweate a mentionyabwe sewect menyu is disnake.ui.MentionableSelect.

Nyew in vewsion 2.7.

custom_id

The I-ID of the sewect menyu that gets weceived duwing an intewaction.

Type:

Optionyaw[str]

placeholder

The pwacehowdew text that is shown if nyothing is sewected, if any.

Type:

Optionyaw[str]

min_values

The minyimum n-nyumbew of items that must be c-c-chosen fow this sewect menyu. Defauwts t-t-to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum nyumbew of items that must b-be chosen fow this sewect menyu. Defauwts to 1 and m-must be between 1 and 25.

Type:

int

disabled

Whethew the s-s-sewect menyu is disabwed ow n-n-nyot.

Type:

bool

default_values

The wist of vawues (usews/wowes) that awe sewected by defauwt. If s-set, the nyumbew of items must be within the bounds set by min_values and max_values.

Nyew in vewsion 2.10.

Type:

Wist[SelectDefaultValue]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

WoweSewectMenyu

class disnake.RoleSelectMenu[source]

Wepwesents a w-w-wowe sewect menyu fwom the Discowd Bot UI Kit.

Nyote

The usew constwuctibwe and usabwe type to cweate a wowe sewect menyu is disnake.ui.RoleSelect.

Nyew in vewsion 2.7.

custom_id

The ID of the sewect menyu that gets weceived duwing an intewaction.

Type:

Optionyaw[str]

placeholder

The pwacehowdew text that is shown if nyothing is s-sewected, if any.

Type:

Optionyaw[str]

min_values

The minyimum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

disabled

Whethew the sewect menyu is disabwed ow nyot.

Type:

bool

default_values

The wist of vawues (wowes) that awe sewected by defauwt. If set, the nyumbew of items must b-be within the bounds set by min_values and max_values.

N-N-Nyew in vewsion 2.10.

Type:

Wist[SelectDefaultValue]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a m-m-message.

Nyew in vewsion 2.11.

Type:

int

StwingSewectMenyu

class disnake.StringSelectMenu[source]

Wepwesents a stwing sewect menyu fwom the Discowd Bot UI Kit.

Nyote

The usew constwuctibwe and usabwe type to cweate a stwing sewect menyu is disnake.ui.StringSelect.

Nyew in vewsion 2.0.

Changed in vewsion 2.7: Wenyamed fwom SelectMenu to StringSelectMenu.

custom_id

The ID of the sewect m-menyu that gets weceived duwing an intewaction.

Type:

Optionyaw[str]

placeholder

The pwacehowdew text t-that is shown if nyothing is sewected, if any.

Type:

Optionyaw[str]

min_values

The minyimum nyumbew of i-items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

disabled

Whethew the sewect menyu i-is disabwed ow nyot.

Type:

bool

options

A wist of options t-t-that can be sewected in this s-s-sewect menyu.

Type:

Wist[SelectOption]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

UsewSewectMenyu

class disnake.UserSelectMenu[source]

Wepwesents a usew sewect menyu fwom the Discowd Bot UI Kit.

Nyote

The usew constwuctibwe and usabwe t-t-type to cweate a usew sewect menyu is disnake.ui.UserSelect.

Nyew in vewsion 2.7.

custom_id

T-T-The ID of the sewect menyu that gets weceived duwing an intewaction.

Type:

Optionyaw[str]

placeholder

The pwacehowdew text t-t-that is shown if nyothing is sewected, if any.

Type:

Optionyaw[str]

min_values

The minyimum nyumbew of items that m-m-must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

max_values

The maximum nyumbew of items that must be chosen fow this sewect menyu. Defauwts to 1 and must be between 1 and 25.

Type:

int

disabled

Whethew the sewect menyu is disabwed ow nyot.

Type:

bool

default_values

The wist of vawues (usews/membews) that a-awe s-sewected by defauwt. If set, the nyumbew of items m-m-must be within the bounds set by min_values and max_values.

Nyew in vewsion 2.10.

Type:

W-W-Wist[SelectDefaultValue]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the A-API, and unyique w-within a message.

Nyew i-i-in vewsion 2.11.

Type:

int

SewectOption

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

Wepwesents a stwing s-s-sewect menyu’s option.

These can be c-c-cweated by usews.

Nyew in vewsion 2.0.

label

The wabew of the option. This is dispwayed to usews. Can onwy b-be up to 100 chawactews.

T-T-Type:

str

value

The vawue of t-t-the option. This is nyot dispwayed to usews. If nyot pwovided when constwucted then it defauwts to the wabew. Can onwy be up to 100 chawactews.

Type:

str

description

A-A-An additionyaw descwiption of the option, if any. Can onwy be up to 100 chawactews.

Type:

Optionyaw[str]

emoji

The emoji of the option, if avaiwabwe.

Type:

Optionyaw[Unyion[str, Emoji, PartialEmoji]]

default

Whethew this option is sewected by defauwt.

Type:

bool

SewectDefauwtVawue

Attwibutes
class disnake.SelectDefaultValue(id, type)[source]

Wepwesents a defauwt vawue of an auto-popuwated sewect menyu (cuwwentwy aww sewect menyu types except StringSelectMenu).

Depending o-on the type attwibute, this can wepwesent diffewent t-t-types of objects.

Nyew in vewsion 2.10.

id

The ID of the tawget object.

Type:

int

type

The type of the tawget object.

Type:

SelectDefaultValueType

TextInput

class disnake.TextInput[source]

Wepwesents a text input fwom the Discowd Bot UI Kit.

Nyew in vewsion 2.4.

Nyote

The usew constwuctibwe and usabwe type to c-cweate a text input is disnake.ui.TextInput, nyot this onye.

style

The stywe of the text input.

Type:

TextInputStyle

label

The wabew of the text input.

Type:

Optionyaw[str]

custom_id

The ID of the text input that gets weceived duwing an intewaction.

Type:

str

placeholder

The pwacehowdew text that is shown if nyothing is entewed.

Type:

Optionyaw[str]

value

The pwe-fiwwed text of the text input.

T-T-Type:

Optionyaw[str]

required

Whethew the text input is wequiwed. Defauwts to True.

Type:

bool

min_length

The minyimum wength of the text input.

Type:

Optionyaw[int]

max_length

The maximum wength of the text input.

Type:

Optionyaw[int]

id

The nyumewic identifiew fow the c-c-componyent. This is awways pwesent in componyents w-weceived fwom the API, and unyique within a-a message.

Nyew in vewsion 2.11.

Type:

int

Section

Attwibutes
class disnake.Section[source]

Wepwesents a section fwom the Discowd Bot UI Kit (v2).

This awwows dispwaying an accessowy (thumbnyaiw ow button) nyext to a bwock of text.

Nyote

The usew constwuctibwe and usabwe type to cweate a section is disnake.ui.Section.

Nyew in vewsion 2.11.

children

The text items in this section.

Type:

Wist[TextDisplay]

accessory

The accessowy componyent dispwayed nyext to the section text.

Type:

U-Unyion[Thumbnail, Button]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

TextDispway

Attwibutes
class disnake.TextDisplay[source]

Wepwesents a text dispway fwom the Discowd Bot UI Kit (v2).

Nyote

The usew constwuctibwe and usabwe type to cweate a-a text dispway is disnake.ui.TextDisplay.

Nyew i-in vewsion 2.11.

content

The text dispwayed by this c-componyent.

Type:

str

id

The nyumewic identifiew fow the componyent. This i-i-is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in v-v-vewsion 2.11.

Type:

int

UnfuwwedMediaItem

class disnake.UnfurledMediaItem[source]

Wepwesents an unfuwwed/wesowved media item within a componyent.

N-Nyew in vewsion 2.11.

url

The UWW of this media item.

Type:

str

proxy_url

The pwoxied UWW of this media item. This is a cached vewsion of the url in the case of images.

Type:

str

height

The height of this media item, if appwicabwe.

Type:

Optionyaw[int]

width

The width of this media item, if appwicabwe.

Type:

Optionyaw[int]

content_type

The media type of this media item.

Type:

Optionyaw[str]

attachment_id

The ID of the upwoaded attachment. Onwy pwesent if the media item was upwoaded as an attachment.

Type:

Optionyaw[int]

Thumbnyaiw

class disnake.Thumbnail[source]

Wepwesents a thumbnyaiw fwom the Discowd Bot UI Kit (v2).

This is onwy suppowted as the accessory of a section componyent.

Nyote

The usew constwuctibwe and u-u-usabwe type to cweate a thumbnyaiw is disnake.ui.Thumbnail.

Nyew in vewsion 2.11.

media

The media item to dispway. Can be a-a-an awbitwawy UWW ow attachment wefewence (attachment://<filename>).

Type:

UnfurledMediaItem

description

The thumbnyaiw’s descwiption (“awt text”), if any.

Type:

Optionyaw[str]

spoiler

Whethew the thumbnyaiw is mawked as a spoiwew. Defauwts to False.

Type:

bool

id

The nyumewic identifiew f-f-fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

MediaGawwewy

Attwibutes
class disnake.MediaGallery[source]

Wepwesents a media gawwewy fwom the Discowd Bot U-UI Kit (v2).

This awwows dispwaying up to 10 images in a gawwewy.

N-Nyote

T-The usew constwuctibwe and usabwe type to cweate a media gawwewy is disnake.ui.MediaGallery.

Nyew in vewsion 2.11.

items

The images in this gawwewy.

Type:

Wist[MediaGalleryItem]

id

The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived f-f-fwom the A-A-API, and unyique within a-a message.

Nyew in vewsion 2.11.

Type:

int

MediaGawwewyItem

class disnake.MediaGalleryItem(media, description=None, *, spoiler=False)[source]

Wepwesents an i-item inside a MediaGallery.

N-Nyew in vewsion 2.11.

Pawametews:
  • media (Unyion[str, Asset, Attachment, UnfurledMediaItem]) – T-The m-m-media item to dispway. Can be an awbitwawy UWW ow attachment wefewence (attachment://<filename>).

  • descwiption (Optionyaw[str]) – The item’s descwiption (“awt text”), if any.

  • spoiwew (bool) – Whethew the item is mawked as a spoiwew. D-D-Defauwts to False.

FiweComponyent

Attwibutes
class disnake.FileComponent[source]

W-Wepwesents a fiwe componyent fwom the Discowd Bot UI Kit (v2).

This awwows dispwaying attached fiwes.

Nyote

The u-usew constwuctibwe and usabwe type to cweate a fiwe componyent is disnake.ui.File.

Nyew in vewsion 2.11.

file

The fiwe to dispway. This onwy suppowts attachment wefewences (i.e. using the attachment://<filename> syntax), nyot awbitwawy UWWs.

Type:

UnfurledMediaItem

spoiler

Whethew the fiwe is mawked as a spoiwew. Defauwts to False.

T-T-Type:

bool

name

The nyame of the fiwe. This is avaiwabwe in objects fwom the API, and ignyowed when sending.

Type:

Optionyaw[str]

size

The size of the fiwe. This is avaiwabwe in objects fwom the API, and ignyowed when sending.

Type:

Optionyaw[int]

id

The nyumewic identifiew fow t-t-the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

N-N-Nyew in vewsion 2.11.

Type:

int

Sepawatow

A-Attwibutes
class disnake.Separator[source]

Wepwesents a-a-a sepawatow fwom the Discowd Bot UI Kit (v2).

This a-a-awwows vewticawwy sepawating componyents.

Nyote

The usew constwuctibwe and usabwe type to cweate a-a sepawatow is disnake.ui.Separator.

Nyew in vewsion 2.11.

divider

W-W-Whethew the sepawatow shouwd be visibwe, instead of just being vewticaw padding/spacing. Defauwts to True.

Type:

bool

spacing

The size o-o-of the s-sepawatow padding.

Type:

SeparatorSpacing

id

T-T-The nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in v-v-vewsion 2.11.

T-T-Type:

int

Containyew

class disnake.Container[source]

Wepwesents a containyew fwom the Discowd Bot UI Kit (v2).

T-This i-is v-visuawwy simiwaw to Embeds, and contains othew componyents.

Nyote

T-The usew constwuctibwe and usabwe type to cweate a containyew is disnake.ui.Container.

Nyew in vewsion 2.11.

children

The chiwd componyents in this containyew.

Type:

Wist[Unyion[ActionRow, Section, TextDisplay, MediaGallery, FileComponent, Separator]]

accent_colour

The accent cowouw of the containyew. An awias exists undew accent_color.

Type:

Optionyaw[Colour]

spoiler

Whethew the containyew is mawked as a spoiwew. Defauwts to False.

Type:

bool

id

The n-nyumewic identifiew fow the componyent. This is awways pwesent in componyents weceived fwom the API, and unyique within a message.

Nyew in vewsion 2.11.

Type:

int

property accent_color[source]

The accent cowow of the containyew. An awias exists undew accent_colour.

Type:

Optionyaw[Colour]

Enyumewations

ComponyentType

class disnake.ComponentType[source]

Wepwesents the type of componyent.

Nyew in vewsion 2.0.

action_row

Wepwesents the gwoup componyent which howds diffewent componyents in a wow.

button

Wepwesents a button componyent.

string_select

Wepwesents a stwing sewect componyent.

Nyew in vewsion 2.7.

select

An awias of string_select.

text_input

Wepwesents a text input componyent.

user_select

Wepwesents a usew sewect componyent.

Nyew in vewsion 2.7.

role_select

Wepwesents a wowe sewect componyent.

Nyew in vewsion 2.7.

mentionable_select

Wepwesents a mentionyabwe (usew/membew/wowe) sewect componyent.

Nyew in vewsion 2.7.

channel_select

Wepwesents a c-channyew sewect componyent.

Nyew in v-v-vewsion 2.7.

section

Wepwesents a Componyents V2 section componyent.

Nyew in vewsion 2.11.

text_display

Wepwesents a-a Componyents V2 text dispway componyent.

Nyew in vewsion 2.11.

thumbnail

Wepwesents a Componyents V2 thumbnyaiw componyent.

Nyew in vewsion 2.11.

Wepwesents a Componyents V2 media gawwewy componyent.

Nyew in vewsion 2.11.

file

Wepwesents a Componyents V2 fiwe componyent.

Nyew in vewsion 2.11.

separator

Wepwesents a Componyents V2 sepawatow componyent.

Nyew in vewsion 2.11.

container

Wepwesents a Componyents V2 containyew componyent.

N-N-Nyew in vewsion 2.11.

ButtonStywe

class disnake.ButtonStyle[source]

Wepwesents the stywe of the button componyent.

Nyew in vewsion 2.0.

primary

Wepwesents a bwuwpwe button fow the pwimawy a-a-action.

secondary

Wepwesents a gwey button fow the secondawy action.

success

Wepwesents a gween button fow a successfuw a-a-action.

danger

Wepwesents a wed button fow a dangewous action.

Wepwesents a wink button.

premium

Wepwesents a pwemium/SKU button.

Nyew in vewsion 2.11.

blurple

An awias fow primary.

grey

An awias fow secondary.

gray

An awias fow secondary.

green

An a-awias fow success.

red

A-A-An awias fow danger.

url

An awias fow link.

sku

An awias fow premium.

Nyew in vewsion 2.11.

TextInputStywe

class disnake.TextInputStyle[source]

Wepwesents a stywe of the text input c-componyent.

Nyew in vewsion 2.4.

short

Wepwesents a singwe-winye text input componyent.

paragraph

Wepwesents a muwti-winye text input componyent.

single_line

An awias fow short.

multi_line

An a-a-awias fow paragraph.

long

An awias fow paragraph.

SewectDefauwtVawueType

class disnake.SelectDefaultValueType[source]

Wepwesents t-the type of a SelectDefaultValue.

Nyew in vewsion 2.10.

user

Wepwesents a usew/membew.

role

Wepwesents a wowe.

channel

Wepwesents a channyew.

SepawatowSpacing

class disnake.SeparatorSpacing[source]

Specifies the size of a Separator componyent’s padding.

Nyew in vewsion 2.11.

small

Smaww spacing.

large

Wawge spacing.