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

Blurple Button Picture
grey

2

gray, Secondary

Grey Button Picture
green

3

Success

Green Button Picture
red

4

Danger

Red Button Picture
url

5

link, grey_url, Link_Button

URL Button Picture

class ActionRow(*components)

Represents an ActionRow-Part for the components of a discord.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 the ActionRow should have. It could contain at least 5 Button or 1 SelectMenu.

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

dictdict The dictionary to convert into an ActionRow.

Returns

ActionRow

to_dict()

Convert this ActionRow in to a dict.

Returns

dict

disable_all_buttons()

Disable all object’s of type Button in this ActionRow.

Returns

ActionRow

disable_all_buttons_if(check, *args)

Disable all Button (s) in this ActionRow if the passed check returns True.

Parameters
  • check – Union[Bool, Callable] Could be a bool or usually any Callable that returns a bool

  • *args – Any Arguments that should passed in to the check if it is a Callable.

Returns

ActionRow

disable_all_select_menus_if(check, *args)

Disables all SelectMenu (s) in this ActionRow if the passed check returns True.

Parameters
  • check – Union[bool, Callable] Could be a bool or usually any Callable that returns a bool.

  • *args – Any Arguments that should passed in to the check if it is a Callable.

Returns

ActionRow

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 the ActionRow.

Returns

ActionRow

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 the ActionRow.

Returns

ActionRow

insert_component_at(index, component)

Inserts a component before a specified index to the ActionRow.

Parameters
  • indexint The index of where to insert the component.

  • component – Union[Button, SelectMenu, dict] The component to insert at the specified index of the ActionRow.

Returns

ActionRow

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
  • indexint 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

ActionRow


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
  • labelstr 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 to ButtonStyle.url

    Warning

    You can’t pass a custom_id and a url because discord don’t send anything when clicking on an URL-Button so it don’t accept both; url/ButtonStyle.url and custom_id!

  • disabledbool Whether the Button is disabled; default False.

disable_if(check, *args)

Disable the Button if the passed check returns True.

Parameters
  • check – typing.Union[bool, Callable] Could be a bool or usually any Callable that returns a bool.

  • *args – Any Arguments that should passed in to the check if it is a Callable

Returns

Button

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 an bool or usually any Callable that returns an bool

  • style – discord.ButtonStyle The style the Button should have when the check returns True

  • *args – Any Arguments that should passed in to the check if it is an Callable.

Returns

Button


class SelectOption(label, value, description, emoji, default)

Represents a option for a SelectMenu.

Parameters
  • labelstr The user-facing name of the option, max 25 characters.

  • valuestr 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.

Parameters
  • custom_id – Union[str, int] A developer-defined identifier for the SelectMenu, max. 100 characters.

  • options – List[SelectOption] A list of choices(SelectOption) the SelectMenu should have, max. 25.

  • placeholder – Optional[str] Custom placeholder text if nothing is selected, max. 100 characters.

  • min_values – Optional[:int] The minimum number of items that must be chosen; default 1, min. 0, max. 25.

  • max_values – Optional[int] The maximum number of items that can be chosen; default 1, max. 25.

  • disabled – Optional[bool] Whether the SelectMenu is disabled or not. False by default.

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 passed check returns True.

Parameters
  • check – Union[bool, Callable] The check could be an bool or usually any Callable that returns an bool.

  • *args – Any Arguments that should passed in to the check if it is an Callable.

Returns

SelectMenu

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

SelectMenu


Indices and tables