discord_slash.component module¶
- discord_slash.component.emoji_to_dict(emoji: Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, str]) dict¶
Converts a default or custom emoji into a partial emoji dict.
- Parameters
emoji (Union[discord.Emoji, discord.PartialEmoji, str]) – The emoji to convert.
- class discord_slash.component.ButtonStyle(value)¶
Bases:
enum.IntEnumAn enumeration.
- blue = 1¶
- gray = 2¶
- grey = 2¶
- green = 3¶
- red = 4¶
- URL = 5¶
- class discord_slash.component.Button(*, label: Optional[str] = None, style: int = ButtonStyle.gray, custom_id: Optional[str] = None, url: Optional[str] = None, disabled: bool = False, emoji: Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, str]] = None)¶
Bases:
discord_slash.component.ComponentCreates a button component for use with the
componentsfield. Must be used within anActionRowto be used (seeActionRow()).Note
At least a label or emoji is required for a button. You can have both, but not neither of them.
- Parameters
style (Union[ButtonStyle, int]) – Style of the button. Refer to
ButtonStyle.label (Optional[str]) – The label of the button.
emoji (Union[discord.Emoji, discord.PartialEmoji, dict]) – The emoji of the button.
custom_id (Optional[str]) – The custom_id of the button. Needed for non-link buttons.
url (Optional[str]) – The URL of the button. Needed for link buttons.
disabled (bool) – Whether the button is disabled or not. Defaults to False.
- Returns
- property emoji: discord.partial_emoji.PartialEmoji¶
- set_emoji(emoji: Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, str])¶
- class discord_slash.component.TextInputStyle(value)¶
Bases:
enum.IntEnumAn enumeration.
- SHORT = 1¶
- PARAGRAPH = 2¶
- class discord_slash.component.TextInput(*, style: Optional[Union[discord_slash.component.TextInputStyle, int]] = None, custom_id: Optional[str] = None, label: Optional[str] = None, min_length: Optional[int] = None, max_length: Optional[int] = None, required: bool = True, value: Optional[str] = None, placeholder: Optional[str] = None)¶
Bases:
discord_slash.component.ComponentCreates a text input component for modal(form). Must be inside an ActionRow to be used (see
ActionRow()).- Parameters
style (Union[TextInputStyle, int]) – Style of the text input. Refer to
TextInputStyle.custom_id (str) – A custom identifier.
label (str) – The label of text input.
placeholer (str) – Custom placeholder text if nothing is inputted.
min_length (int) – The minimum input length for a text input.
max_length (int) – The maximum input length for a text input.
value (str) – A pre-filled value.
- Returns
- property custom_id¶
- property style¶
- property label¶
- property min_length¶
- property max_length¶
- property required¶
- property value¶
- property placeholder¶
- class discord_slash.component.Modal(*, custom_id: Optional[str] = None, title: Optional[str] = None, components: Optional[List[discord_slash.component.TextInput]] = None)¶
Bases:
discord_slash.component.ComponentCreates a popup modal(form).
- Parameters
- Returns
- class discord_slash.component.Select(*, options: List[discord_slash.component.SelectOption], custom_id: Optional[str] = None, placeholder: Optional[str] = None, min_values: int = 1, max_values: int = 1, disabled: bool = False)¶
Bases:
discord_slash.component.ComponentCreates a select (dropdown) component for use with the
componentsfield. Must be inside an ActionRow to be used (seeActionRow()).- Parameters
options (List[SelectOption]) – The choices the user can pick from.
custom_id (str) – A custom identifier, like buttons.
placeholder (str) – Custom placeholder text if nothing is selected.
min_values (int) – The minimum number of items that must be chosen.
max_values (int) – The maximum number of items that can be chosen.
disabled (bool) – Disables this component. Defaults to
False.
- Returns
- property options: List[discord_slash.component.SelectOption]¶
- set_options(value: List[discord_slash.component.SelectOption])¶
- class discord_slash.component.SelectOption(*, label: str, value: str, emoji: Optional[Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, str]] = None, description: Optional[str] = None, default: bool = False)¶
Bases:
discord_slash.component.ComponentCreates an option for Select components.
- Parameters
label (str) – The user-facing name of the option that will be displayed in discord client.
value (str) – The value that the bot will receive when this option is selected.
emoji (Union[Emoji, PartialEmoji, str]) – The emoji of the option.
description (str) – An additional description of the option.
default (bool) – Whether or not this is the default option.
- Returns
- property emoji: Optional[discord.partial_emoji.PartialEmoji]¶
- set_emoji(emoji: Union[discord.emoji.Emoji, discord.partial_emoji.PartialEmoji, str])¶
- class discord_slash.component.ActionRow(*args: List[discord_slash.component.Component])¶
Bases:
discord_slash.component.ComponentActionRow for message components.
- Parameters
components – Components to go within the ActionRow.
- Returns
- disable_components() List[discord_slash.component.Component]¶
- append(component: discord_slash.component.Component)¶
- property components: List[discord_slash.component.Component]¶
- set_components(value: List[discord_slash.component.Component])¶
- add_component(value: discord_slash.component.Component)¶
- remove_component(value: discord_slash.component.Component)¶