Components¶
- class ButtonStyle¶
This is located in discord.enums but i place it here.
The possible styles for a
ButtonNAME
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-API Documentation.
Note
You could use a
listinstead of this but you don’t have the functions and parameters of this class then.- Parameters
components – Union[
Button,SelectMenu] The components theActionRowshould have. It could contain at least 5Buttonor 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 –
dictThe dictionary to convert into an ActionRow.- Returns
- disable_all_buttons_if(check, *args)¶
Disable all
Button(s) in thisActionRowif the passedcheckreturnsTrue.- Parameters
check – Union[Bool, Callable] Could be a
boolor usually anyCallablethat returns abool*args – Any Arguments that should passed in to the
checkif it is aCallable.
- Returns
Disables all
SelectMenu(s) in thisActionRowif the passedcheckreturnsTrue.- Parameters
check – Union[
bool, Callable] Could be aboolor usually anyCallablethat returns abool.*args – Any Arguments that should passed in to the
checkif 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 –
intThe 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 –
intThe 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-ButtonNote
For general information about Discord-Button’s visit the Documentation of the discord-api.
- Parameters
label –
strThe 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 –
ButtonStyleThe Style the Button should have.Note
To get more infos about the styles visit the Discord-API 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
stylewill automatic set toButtonStyle.urlWarning
You can’t pass a
custom_idand aurlbecause discord don’t send anything when clicking on anURL-Buttonso it don’t accept both;url/ButtonStyle.urlandcustom_id!disabled –
boolWhether the Button is disabled; default False.
- disable_if(check, *args)¶
Disable the
Buttonif the passedcheckreturnsTrue.- Parameters
check – typing.Union[
bool, Callable] Could be aboolor usually anyCallablethat returns abool.*args – Any Arguments that should passed in to the
checkif it is aCallable
- Returns
- set_style_if(check, style, *args)¶
Sets the style of the
Buttonto the specified one if the specified check returns True.- Parameters
check – Union[
bool,typing.Callable] The check could be anboolor usually anyCallablethat returns anboolstyle – discord.ButtonStyle The style the
Buttonshould have when thecheckreturns True*args – Any Arguments that should passed in to the
checkif it is anCallable.
- Returns
- class SelectOption(label, value, description, emoji, default)¶
Builds you a dict which can be used as an option for a
SelectMenu- Parameters
label –
strThe user-facing name of the option, max 25 characters.value –
strThe 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-MenuNote
For general information about Select-Menus visit the Discord-API-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
SelectMenuif the passedcheckreturnsTrue.- Parameters
check – Union[
bool, Callable] The check could be anboolor usually anyCallablethat returns anbool.*args – Any Arguments that should passed in to the
checkif 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