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¶
- class disnake.Component[source]¶
Wepwesents the base componyent that aww othew componyents inhewit fwom.
The componyents suppowted b-b-by Discowd awe:
subtypes of
BaseSelectMenu(ChannelSelectMenu,MentionableSelectMenu,RoleSelectMenu,StringSelectMenu,UserSelectMenu)
This cwass is abstwact and cannyot be instantiated.
Nyew i-i-in vewsion 2.0.
- type¶
The type of componyent.
- Type:
- 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:
ActionWow¶
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:
- 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:
- 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]]
SewectDefauwtVawue¶
- 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
typeattwibute, this can wepwesent diffewent t-t-types of objects.Nyew in vewsion 2.10.
- type¶
The type of the tawget object.
- Type:
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:
Section¶
- 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.
TextDispway¶
- 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.
UnfuwwedMediaItem¶
- class disnake.UnfurledMediaItem[source]¶
Wepwesents an unfuwwed/wesowved media item within a componyent.
N-Nyew in vewsion 2.11.
- proxy_url¶
The pwoxied UWW of this media item. This is a cached vewsion of the
urlin the case of images.- Type:
- content_type¶
The media type of this media item.
- Type:
Optionyaw[
str]
Thumbnyaiw¶
- class disnake.Thumbnail[source]¶
Wepwesents a thumbnyaiw fwom the Discowd Bot UI Kit (v2).
This is onwy suppowted as the
accessoryof 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:
MediaGawwewy¶
- 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]
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 toFalse.
FiweComponyent¶
- 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:
- name¶
The nyame of the fiwe. This is avaiwabwe in objects fwom the API, and ignyowed when sending.
- Type:
Optionyaw[
str]
Sepawatow¶
- 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:
- spacing¶
The size o-o-of the s-sepawatow padding.
- Type:
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]
- 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:
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.
- media_gallery¶
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.