Components¶
- class ButtonStyle¶
This is located in discord.enums but i place it here.
The possible styles for a
Button
NAME
VALUE
ALIASES
EXAMPLE
- blurple¶
1
Primary
- grey¶
2
gray
,Secondary
- green¶
3
Success
- red¶
4
Danger
- url¶
5
link
,grey_url
,Link_Button
- class ActionRow(*components)¶
Represents an
ActionRow
-Part for the components of adiscord.Message
.Note
For general information about ActionRow’s visit the Discord-APIMethodes Documentation.
Note
You could use a
list
instead of this but you don’t have the functions and parameters of this class then.- Parameters
components – Union[
Button
,SelectMenu
] The components theActionRow
should have. It could contain at least 5Button
or 1SelectMenu
.
- classmethod from_dict(data)¶
Converts a dict (e.g. created with
to_dict()
) into an ActionRow, provided it is in the format Discord expects.You can read about this format in the official Discord documentation.
- Parameters
dict –
dict
The dictionary to convert into an ActionRow.- Returns
- disable_all_buttons_if(check, *args)¶
Disable all
Button
(s) in thisActionRow
if the passedcheck
returnsTrue
.- Parameters
check – Union[Bool, Callable] Could be a
bool
or usually anyCallable
that returns abool
*args – Any Arguments that should passed in to the
check
if it is aCallable
.
- Returns
Disables all
SelectMenu
(s) in thisActionRow
if the passedcheck
returnsTrue
.- Parameters
check – Union[
bool
, Callable] Could be abool
or usually anyCallable
that returns abool
.*args – Any Arguments that should passed in to the
check
if it is aCallable
.
- Returns
- add_component(component)¶
Adds a component to the
ActionRow
.This function returns the class instance to allow for fluent-style chaining.
- Parameters
component – Union[
Button
,SelectMenu
,dict
] The component to add to theActionRow
.- Returns
- add_components(*components)¶
Add multiple components to the
ActionRow
.This function returns the class instance to allow for fluent-style chaining.
- Parameters
*components – *Union[
Button
,SelectMenu
,dict
] The components to add to theActionRow
.- Returns
- insert_component_at(index, component)¶
Inserts a component before a specified index to the
ActionRow
.- Parameters
index –
int
The index of where to insert the component.component – Union[
Button
,SelectMenu
,dict
] The component to insert at the specified index of theActionRow
.
- Returns
- set_component_at(index, component)¶
Modifies a component to the ActionRow object.
The index must point to a valid pre-existing component.
This function returns the class instance to allow for fluent-style chaining.
- Parameters
index –
int
The index of the component to modify.component – Union[
Button
,SelectMenu
,dict
] The component to replace the old one with.
- Raises
IndexError – An invalid index was provided.
- Returns
- class Button(label, custom_id, style, emoji, url, disabled)¶
Represents a
Discord-Button
Note
For general information about Discord-Button’s visit the Documentation of the discord-api.
- Parameters
label –
str
The Text displayed in discord on the Button. Maximal length is 80 Chars.custom_id – Union[
str
,int
] The custom_id discord send us when a User press the Button. The max. length of this is 100.style –
ButtonStyle
The Style the Button should have.Note
To get more infos about the styles visit the Discord-APIMethodes Documentation.
emoji – Optional[Union[
discord.PartialEmoji
,discord.Emoji
,str
]] The Emoji that will be displayed on the left side of the Button.url –
Optional[
str
] The URL the Button links too.Note
If you set this, the
style
will automatic set toButtonStyle.url
Warning
You can’t pass a
custom_id
and aurl
because discord don’t send anything when clicking on anURL-Button
so it don’t accept both;url
/ButtonStyle.url
andcustom_id
!disabled –
bool
Whether the Button is disabled; default False.
- disable_if(check, *args)¶
Disable the
Button
if the passedcheck
returnsTrue
.- Parameters
check – typing.Union[
bool
, Callable] Could be abool
or usually anyCallable
that returns abool
.*args – Any Arguments that should passed in to the
check
if it is aCallable
- Returns
- set_style_if(check, style, *args)¶
Sets the style of the
Button
to the specified one if the specified check returns True.- Parameters
check – Union[
bool
,typing.Callable
] The check could be anbool
or usually anyCallable
that returns anbool
style – discord.ButtonStyle The style the
Button
should have when thecheck
returns True*args – Any Arguments that should passed in to the
check
if it is anCallable
.
- Returns
- class SelectOption(label, value, description, emoji, default)¶
Represents a option for a
SelectMenu
.- Parameters
label –
str
The user-facing name of the option, max 25 characters.value –
str
The dev-define value of the option, max 100 characters.description – Optional[
str
] An additional description of the option, max 50 characters.emoji – Optional[Union[
PartialEmoji
,Emoji
,str
]] An Emoji that will be displayed on the left side of the option.default – Optional[
bool
] Whether this option is selected by default.
- class SelectMenu(custom_id, options, placeholder, min_values, max_values, disabled)¶
Represents a
Discord-Select-Menu
Note
For general information about Select-Menus visit the Discord-APIMethodes-Documentation.
all_option_values
: Generator[Union[str
,int
]]Returns a generator with all values of the options of the
SelectMenu
.If the value is a number it is returned as an integer, otherwise a string
Note
This is equal to
for option in select.options: if option.value.isdigit(): yield int(option.value) else: yield option.value
- yield
Union[
str
,int
]
- disable_if(check, *args)¶
Disables the
SelectMenu
if the passedcheck
returnsTrue
.- Parameters
check – Union[
bool
, Callable] The check could be anbool
or usually anyCallable
that returns anbool
.*args – Any Arguments that should passed in to the
check
if it is anCallable
.
- Returns
- set_custom_id(custom_id)¶
Set the custom_id of the
SelectMenu
- Parameters
custom_id – Union[
str
,int
] The custom_id to replace the old one with- Returns