View¶
discord_http.view module¶
- class discord_http.view.ActionRow(*components)¶
Bases:
Item
Represents an action row component in a message, containing buttons, selects, and links.
- class discord_http.view.AttachmentComponent(*, state, data)¶
Bases:
object
Represents an attachment component.
- Parameters:
state (DiscordAPI)
data (dict)
- async fetch(*, use_cached=False) bytes ¶
Fetches the file from the attachment URL and returns it as bytes.
- Parameters:
use_cached (
bool
) – Whether to use the cached URL or not, defaults to False- Return type:
- Returns:
The attachment as bytes
- Raises:
HTTPException – If the request returned anything other than 2XX
- async save(path, *, use_cached=False) int ¶
Fetches the file from the attachment URL and saves it locally to the path.
- class discord_http.view.Button(*, label=None, style=ButtonStyles.primary, disabled=False, custom_id=None, sku_id=None, emoji=None, url=None)¶
Bases:
Item
Represents a button component in a message.
- Parameters:
- style¶
The style of the button
- Type:
ButtonStyles | str | int
- class discord_http.view.ChannelSelect(*channels, placeholder=None, custom_id=None, min_values=1, max_values=1, default_values=None, disabled=False, label=None, description=None, required=False)¶
Bases:
Select
Represents a channel select menu component in a message.
- Parameters:
channels (ChannelType | BaseChannel)
placeholder (str | None)
custom_id (str | None)
min_values (int | None)
max_values (int | None)
default_values (list[BaseChannel | int] | None)
disabled (bool)
label (str | None)
description (str | None)
required (bool)
- class discord_http.view.ContainerComponent(*items, colour=None, spoiler=None)¶
Bases:
Item
Represents a container component in a message.
- class discord_http.view.FileComponent(file, *, spoiler=False)¶
Bases:
Item
Represents a file component in a message.
- Parameters:
file (Asset | AttachmentComponent | str)
spoiler (bool)
- file¶
The file to be sent
- Type:
- class discord_http.view.Item(*, type)¶
Bases:
object
Base class for all components in discord.http API.
- Parameters:
type (ComponentType)
- class discord_http.view.Link(*, url, label=None, emoji=None, disabled=False)¶
Bases:
Button
Button alias for the link style.
- url¶
URL to open when the button is clicked
- label¶
Label of the button
- emoji¶
Emoji shown on the left side of the button
- disabled¶
Whether the button is disabled or not
- class discord_http.view.MediaGalleryComponent(*items)¶
Bases:
Item
Represents a media gallery component in a message.
- Parameters:
items (MediaGalleryItem | File | Asset | str)
- items¶
The items contained within the media gallery
- Type:
MediaGalleryItem | File | Asset | str
- class discord_http.view.MediaGalleryItem(url, *, description=None, spoiler=False)¶
Bases:
object
Represents an item in a media gallery.
- url¶
The URL of the media item, can be a file, asset, attachment component, or a string URL
- Type:
File | Asset | AttachmentComponent | str
- class discord_http.view.MentionableSelect(*, placeholder=None, custom_id=None, min_values=1, max_values=1, default_values=None, disabled=False, label=None, description=None, required=False)¶
Bases:
Select
Represents a mentionable select menu component in a message.
- Parameters:
- default_values¶
The default selected values for the mentionable select menu
- class discord_http.view.Modal(*, title, custom_id=None)¶
Bases:
InteractionStorage
Represents a modal component in a message.
- add_item(component, *, label=None, description=None) LabelComponent | TextDisplayComponent ¶
Add an item to the modal.
- Parameters:
component (
TextDisplayComponent
|TextInputComponent
|Select
) – The component to add to the modallabel (
str
|None
) – The label of the component, overwrites component.labeldescription (
str
|None
) – The description of the component, overwrites component.description, by default None
- Return type:
LabelComponent
|TextDisplayComponent
- Returns:
The created label component
- Raises:
TypeError – If the component is not a TextInputComponent or Select
- class discord_http.view.Premium(sku_id)¶
Bases:
Button
Button alias for the premium SKU style.
- sku_id¶
SKU ID of the premium button
- class discord_http.view.RoleSelect(*, placeholder=None, custom_id=None, min_values=1, max_values=1, default_values=None, disabled=False, label=None, description=None, required=False)¶
Bases:
Select
Represents a role select menu component in a message.
- Parameters:
- class discord_http.view.SectionComponent(*components, accessory)¶
Bases:
Item
Represents a section component in a message.
- Parameters:
components (TextDisplayComponent | str)
accessory (Button | ThumbnailComponent | AttachmentComponent | Asset | File | str)
- components¶
The components contained within the section
- Type:
- accessory¶
The accessory component for the section
- Type:
Button | ThumbnailComponent | AttachmentComponent | Asset | File | str
- class discord_http.view.Select(*, label=None, description=None, placeholder=None, custom_id=None, min_values=1, max_values=1, disabled=False, options=None, required=None, _type=None)¶
Bases:
Item
Represents a select menu component in a message.
- Parameters:
- add_item(*, label, value, description=None, emoji=None, default=False) None ¶
Add an item to the select menu.
- Parameters:
- Raises:
ValueError – If there are more than 25 options
- Return type:
- class discord_http.view.SeparatorComponent(*, spacing=None, divider=None)¶
Bases:
Item
Represents a separator component in a message.
- Parameters:
spacing (SeparatorSpacingType | None)
divider (bool | None)
- spacing¶
The spacing type of the separator
- Type:
SeparatorSpacingType | None
- class discord_http.view.TextDisplayComponent(content)¶
Bases:
Item
Represents a text display component in a message.
- Parameters:
content (str)
- class discord_http.view.TextInputComponent(*, label=None, description=None, custom_id=None, style=None, placeholder=None, min_length=None, max_length=None, default=None, required=True)¶
Bases:
Item
Represents a text input component in a modal.
- Parameters:
- style¶
The style of the text input
- Type:
TextStyles | None
- class discord_http.view.ThumbnailComponent(url, *, description=None, spoiler=False)¶
Bases:
Item
Represents a thumbnail component in a message.
- Parameters:
url (Asset | AttachmentComponent | str)
description (str | None)
spoiler (bool)
- url¶
The URL of the thumbnail image
- Type:
- class discord_http.view.UserSelect(*, placeholder=None, custom_id=None, min_values=1, max_values=1, default_values=None, disabled=False, label=None, description=None, required=False)¶
Bases:
Select
Represents a user select menu component in a message.
- Parameters:
- class discord_http.view.View(*items)¶
Bases:
InteractionStorage
Represents a view component in a message.
- Parameters:
items (Item)
- classmethod from_dict(*, state, data) View ¶
Returns a view from a dict provided by Discord.
- Return type:
- Parameters:
state (DiscordAPI)
data (dict)
- get_item(*, label=None, custom_id=None) Item | None ¶
Get an item from the view that matches the parameters.