Appearance
discohook.components
Classes
- ActionRow
- Checkbox
- CheckboxGroup
- CheckboxGroupOption
- Container
- FileUpload
- Label
- Media
- MediaGallery
- RadioGroup
- RadioGroupOption
- Section
- Separator
- TextDisplay
- TextInput
- Thumbnail
ActionRow
discohook.components.ActionRow
Action row component.
Arguments
- components (
Tuple[Button | Select]): Components to include in the action row. Must be between 1 and 5 components. - id (
int | None): Unique id for the action row.
Attributes
- id (
int): Action row id. - type (
ComponentType): Action row type. - components (
List[Component]): Action row components.
Checkbox
discohook.components.Checkbox
Represents a checkbox component in a modal.
Arguments
- custom_id (
str): A unique id of the checkbox field. Must be a valid python identifier. - id (
int | None): A unique id of the checkbox field. Must be a valid python identifier. - default (
bool): Whether this checkbox is checked by default (defaults to false).
CheckboxGroup
discohook.components.CheckboxGroup
Represents a group of checkboxes in a modal.
Arguments
- custom_id (
str): A unique id of the checkbox group. Must be a valid python identifier. - options (
List[CheckboxGroupOption]): A list of checkbox options in the group. - min_values (
int | None): Minimum number of checkboxes that must be checked (defaults to None). - max_values (
int | None): Maximum number of checkboxes that can be checked (defaults to None). - required (
bool): Whether this component is required to be filled (defaults to true).
CheckboxGroupOption
discohook.components.CheckboxGroupOption
Represents an option in a checkbox group.
Arguments
- label (
str): The label of the checkbox option. - value (
str): The value of the checkbox option. - description (
str | None): The description of the checkbox option. - default (
bool): Whether this checkbox option is checked by default (defaults to false).
Container
discohook.components.Container
Container component.
Arguments
*components (Tuple[ActionRow | TextDisplay | Section | MediaGallery | Separator | File]): Components to include in the container. Must be between 1 and 10 components.
- accent_color (
int | None): Optional accent color for the container. - id (
int | None): Unique id for the container.
Attributes
- attachments (
List[File]): List of attachments in the container.
FileUpload
discohook.components.FileUpload
Represents a file upload component in a modal.
Arguments
- id (
int): A unique id of the file upload field. Must be a valid python identifier. - min_values (
int): Minimum number of items that must be uploaded (defaults to 1) - max_values (
int): Maximum number of items that must be uploaded (defaults to 1) - required (
bool): Whether this component is required to be filled (defaults to true).
Label
discohook.components.Label
Represents a label component in a modal.
Arguments
- label (
str): The text of the label. - child (
Select | TextInput | FileUpload | Checkbox | CheckboxGroup | RadioGroup): Child component for the label. - id (
int | None): Optional unique id of the label. - description (
str | None): The description of the label.
Media
discohook.components.Media
Media component.
Arguments
- media (
str | File): Media to include in the media component. - description (
str | None): Media description. - spoiler (
bool): Whether the media should be spoiler or not.
MediaGallery
discohook.components.MediaGallery
Media gallery component.
Arguments
*media (Media): Media items to include in the gallery.
- id (
int | None): Unique id for the media gallery.
Attributes
- id (
int): Media gallery id. - type (
ComponentType): Media gallery type. - items (
Tuple[Media]): Media items in the gallery. - attachments (
List[File]): Attachments for the media items.
RadioGroup
discohook.components.RadioGroup
Represents a group of radio buttons in a modal.
Arguments
- custom_id (
str): A unique id of the radio group. Must be a valid python identifier. - options (
List[RadioGroupOption]): A list of radio options in the group. - required (
bool): Whether this component is required to be filled (defaults to true).
RadioGroupOption
discohook.components.RadioGroupOption
Represents an option in a radio group.
Arguments
- label (
str): Label of the radio option. - value (
str): Value of the radio option. - description (
str | None): Description of the radio option. - default (
bool): Whether this radio option is selected by default (defaults to false).
Section
discohook.components.Section
Section component.
Arguments
*components (Tuple[TextDisplay]): Text display components to include in the section.
- accessory (
Button | Thumbnail): Accessory component for the section. - id (
int | None): Unique id for the section.
Attributes
- attachment (
File | None): Attachment for the accessory if it is a File.
Separator
discohook.components.Separator
Separator component.
Arguments
- id (
int | None): Optional separator id. - spacing (
int): The spacing of the separator. Must be either 1 or 2.
Raises
- AssertionError: If spacing is not 1 or 2.
TextDisplay
discohook.components.TextDisplay
Text display component.
Arguments
- markdown (
str): Markdown content to display. - id (
int | None): Unique id for the text display.
Attributes
- id (
int | None): Optional text display id. - type (
ComponentType): Text display type. - content (
str): Markdown content to display.
TextInput
discohook.components.TextInput
Represents a text input field in a modal.
Arguments
- custom_id (
str): Custom id of the text input field. Must be a valid python identifier. - id (
int | None): Optional unique id of the text input field. - required (
bool): Whether this component is required to be filled (defaults to true). - placeholder (
str | None): Custom placeholder text if the input is empty; max 100 characters. - value (
str | None): Pre-filled value for this component; max 4000 characters. - min_length (
int): Minimum length of the text input field. - max_length (
int): Maximum length of the text input field. - style (
TextInputFieldLength): The style of the text input field.
Thumbnail
discohook.components.Thumbnail
Thumbnail component.
Arguments
- media (
str | File): Media to include in the thumbnail. - description (
str | None): Thumbnail description. - spoiler (
bool): Whether the thumbnail should be spoiler or not. - id (
int | None): Unique id for the thumbnail.
Attributes
- attachment (
File | None): Attachment for the thumbnail if media is a File.
