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.

Parameters:

components (Button | Select | Link)

type: ComponentType

The type of the component.

components: list[Button | Select | Link]

The components contained within the action row.

add_item(item) → None

Add an item to the action row.

Parameters:

item (Button | Select | Link) – The item to add to the action row

Return type:

None

remove_items(*, label=None, custom_id=None) → int

Remove items from the action row.

Parameters:
  • label (str | None) – Label of the item

  • custom_id (str | None) – Custom ID of the item

Return type:

int

Returns:

Returns the amount of items removed

to_dict() → dict

Returns a dict representation of the action row.

Return type:

dict

classmethod from_dict(data) → ActionRow

Returns an action row from a dict provided by Discord.

Return type:

ActionRow

Parameters:

data (dict)

class discord_http.view.AttachmentComponent(*, state, data)

Bases: object

Represents an attachment component.

Parameters:
spoiler: bool

Whether the attachment is a spoiler or not.

filename: str | None

The filename of the attachment, if any.

size: int

The size of the attachment in bytes.

url: str

The URL of the attachment.

proxy_url: str | None

The proxied URL of the attachment, if any.

height: int | None

The height of the attachment, if any.

width: int | None

The width of the attachment, if any.

placeholder: str | None

The placeholder of the attachment, if any.

placeholder_version: int | None

The placeholder version of the attachment, if any.

content_type: str | None

The content type of the attachment, if any.

flags: int

The flags of the attachment, if any.

attachment_id: int | None

The ID of the uploaded attachment, if the media was uploaded as one.

content_scan_flags: ContentScanFlags | None

The flags from Discord’s content scanning, if the media has been scanned.

async fetch(*, use_cached=False) → bytes

Fetches the file from the attachment URL and returns it as bytes.

Media that was not uploaded to Discord points at whatever URL the author of the message chose. That is always fetched through Discord’s proxy, so the bot never connects to a host picked by a user.

Parameters:

use_cached (bool) – Whether to use the cached URL or not, defaults to False

Return type:

bytes

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.

Parameters:
  • path (str) – Path to save the file to, which includes the filename and extension. Example: ./path/to/file.png

  • use_cached (bool) – Whether to use the cached URL or not, defaults to False

Return type:

int

Returns:

The amount of bytes written to the file

async to_file(*, filename, spoiler=False) → File

Convert the attachment to a sendable File object for Message.send().

Parameters:
  • filename (str) – Filename for the file, if empty, the attachment’s filename will be used

  • spoiler (bool) – Weather the file should be marked as a spoiler or not, defaults to False

Return type:

File

Returns:

The attachment as a File object

to_dict() → dict

Returns a dict representation of the attachment.

Return type:

dict

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:
label: str | None

The label of the button.

disabled: bool

Whether the button is disabled or not.

url: str | None

The URL of the button, only required for link buttons.

emoji: str | dict | None

The emoji associated with the button.

sku_id: Snowflake | int | None

The SKU ID of the button, only required for premium buttons.

style: ButtonStyles | str | int

The style of the button.

custom_id: str | None

The custom ID of the button.

to_dict() → dict

Returns a dict representation of the button.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.ChannelSelect(channel_types, 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:
channel_types: list[ChannelType]

The channel types that can be selected.

to_dict() → dict

Returns a dict representation of the channel select menu.

Return type:

dict

add_item(*, label, value, description=None, emoji=None, default=False) → None

Add an item to the select menu.

Parameters:
  • label (str) – Label of the item

  • value (str) – The value of the item, which will be shown on interaction response

  • description (str | None) – Description of the item

  • emoji (str | None) – Emoji shown on the left side of the item

  • default (bool) – Whether the item is selected by default

Raises:

ValueError – If there are more than 25 options

Return type:

None

custom_id: str

The custom ID of the select menu.

description: str | None

The description of the select menu (only works for modals).

disabled: bool

Whether the select menu is disabled or not.

label: str | None

The label of the select menu (only works for modals).

max_values: int | None

The maximum number of values that can be selected.

min_values: int | None

The minimum number of values that can be selected.

options
placeholder: str | None

The placeholder text for the select menu.

required: bool | None

Whether the select menu is required or not (only works for modals).

type: ComponentType

The type of the component.

class discord_http.view.CheckboxComponent(*, custom_id=None, label=None, description=None, default=False)

Bases: Item

Represents a checkbox component in a modal.

This is a single checkbox component, and returns a boolean value on interaction.

Parameters:
  • custom_id (str | None)

  • label (str | None)

  • description (str | None)

  • default (bool)

custom_id: str

The custom ID of the checkbox component.

label: str | None

The label of the checkbox component.

description: str | None

The description of the checkbox component.

default: bool

Whether the checkbox is checked by default.

to_dict() → dict

Returns a dict representation of the checkbox component.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.CheckboxGroupComponent(*options, custom_id=None, label=None, description=None, min_values=1, max_values=None, required=True)

Bases: Item

Represents a checkbox group component in a modal.

Parameters:
custom_id: str

The custom ID of the checkbox group component.

options: list[ComponentOption]

The options for the checkbox group component.

label: str | None

The label of the checkbox group component.

description: str | None

The description of the checkbox group component.

min_values: int

The minimum number of values that can be selected.

max_values: int | None

The maximum number of values that can be selected.

required: bool

Whether the checkbox group component is required or not.

add_item(value, label, description=None, default=False) → None

Add an item to the checkbox group component.

Parameters:
  • value (str) – The value of the option, which will be returned on interaction response

  • label (str) – The label of the option, what the user sees

  • description (str | None) – The description of the option, additional text shown below the label

  • default (bool) – Whether the option is selected by default

Return type:

None

to_dict() → dict

Returns a dict representation of the checkbox group component.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.CheckpointComponent(*_, **kwargs)

Bases: LockedItem

Represents a checkpoint component in a message.

This is used for the checkpoint feature in Discord.

Parameters:
to_dict() → dict

Returns a dict representation of the content inventory entry.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.ComponentOption(*, label, value, description=None, default=False)

Bases: object

Represents an option for radio and checkbox components.

Parameters:
  • label (str)

  • value (str)

  • description (str | None)

  • default (bool)

label: str

The label of the option.

value: str

The value of the option.

description: str | None

The description of the option.

default: bool

Whether the option is the default selection.

to_dict() → dict

Returns a dict representation of the option.

Return type:

dict

class discord_http.view.ContainerComponent(*items, colour=None, spoiler=None)

Bases: Item

Represents a container component in a message.

Parameters:
type: ComponentType

The type of the component.

items: list[Item]

The items contained within the container.

colour: Colour | int | None

The colour of the container, can be a Colour object or an integer.

spoiler: bool | None

Whether the container is marked as a spoiler.

add_item(item) → Item

Add an item to the container component.

Parameters:

item (Item) – The item to add to the container component

Return type:

Item

Returns:

Returns the item that was added

remove_index(index) → Item | None

Remove an item from the container component.

Parameters:

index (int) – The index of the item to remove

Return type:

Item | None

Returns:

Returns whether the item was removed

to_dict() → dict

Returns a dict representation of the container component.

Return type:

dict

class discord_http.view.ContentInventoryEntry(*_, **kwargs)

Bases: LockedItem

Represents a content inventory entry component in a message.

This is used for the content inventory feature in Discord.

Parameters:
to_dict() → dict

Returns a dict representation of the content inventory entry.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.FileComponent(file, *, spoiler=False)

Bases: Item

Represents a file component in a message.

Parameters:
type: ComponentType

The type of the component.

file: File | Asset | AttachmentComponent | str

The file to be sent.

spoiler: bool

Whether the file is a spoiler.

to_dict() → dict

Returns a dict representation of the file component.

Return type:

dict

class discord_http.view.FileUploadComponent(*, custom_id=None, min_values=None, max_values=None, label=None, description=None, required=True, file_types=None)

Bases: Item

Represents a file upload component in a modal.

Parameters:
  • custom_id (str | None)

  • min_values (int | None)

  • max_values (int | None)

  • label (str | None)

  • description (str | None)

  • required (bool)

  • file_types (list[str] | None)

custom_id: str

The custom ID of the file upload component.

min_values: int | None

The minimum number of values that can be uploaded.

max_values: int | None

The maximum number of values that can be uploaded.

required: bool

Whether the file upload component is required or not.

label: str | None

The label of the file upload component.

description: str | None

The description of the file upload component.

file_types: list[str] | None

List of allowed extensions, can be image, video, audio or any dot-prefixed extensions such as .pdf

to_dict() → dict

Returns a dict representation of the file upload component.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.Item(*, type)

Bases: object

Base class for all components in discord.http API.

Parameters:

type (ComponentType)

type: ComponentType

The type of the component.

to_dict() → dict

Returns a dict representation of the item.

Return type:

dict

class discord_http.view.LabelComponent(*, label, description=None, component)

Bases: Item

Represents a label component in a modal.

Parameters:
type: ComponentType

The type of the component.

component: TextInputComponent | Select | FileUploadComponent | RadioComponent | CheckboxGroupComponent | CheckboxComponent

The component contained within the label.

label: str | None

The label of the component.

description: str | None

The description of the component.

to_dict() → dict

Returns a dict representation of the label component.

Return type:

dict

Bases: Button

Button alias for the link style.

Parameters:
  • url (str)

  • label (str | None)

  • emoji (str | None)

  • disabled (bool)

custom_id: str | None

The custom ID of the button.

disabled: bool

Whether the button is disabled or not.

emoji: str | dict | None

The emoji associated with the button.

label: str | None

The label of the button.

sku_id: Snowflake | int | None

The SKU ID of the button, only required for premium buttons.

style: ButtonStyles | str | int

The style of the button.

to_dict() → dict

Returns a dict representation of the button.

Return type:

dict

type: ComponentType

The type of the component.

url: str | None

The URL of the button, only required for link buttons.

class discord_http.view.LockedItem(*, type, **kwargs)

Bases: Item

Used for valid components, but cannot be used directly.

Parameters:
type: ComponentType

The type of the component.

to_dict() → dict

Returns a dict representation of the content inventory entry.

Return type:

dict

class discord_http.view.MediaGalleryComponent(*items)

Bases: Item

Represents a media gallery component in a message.

Parameters:

items (MediaGalleryItem | File | Asset | str)

type: ComponentType

The type of the component.

items: list[MediaGalleryItem | File | Asset | str]

The items contained within the media gallery.

add_item(item, *, description=None, spoiler=False) → None

Add items to the media gallery.

Parameters:
Return type:

None

to_dict() → dict

Returns a dict representation of the media gallery component.

Return type:

dict

class discord_http.view.MediaGalleryItem(url, *, description=None, spoiler=False)

Bases: object

Represents an item in a media gallery.

Parameters:
url: File | Asset | AttachmentComponent | str

The URL of the media item, can be a file, asset, attachment component, or a string URL.

description: str | None

The description of the media item.

spoiler: bool

Whether the media item is marked as a spoiler.

to_dict() → dict

Returns a dict representation of the media gallery item.

Return type:

dict

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:
  • placeholder (str | None)

  • custom_id (str | None)

  • min_values (int | None)

  • max_values (int | None)

  • default_values (list[Member | Role | int] | None)

  • disabled (bool)

  • label (str | None)

  • description (str | None)

  • required (bool)

add_item(*, label, value, description=None, emoji=None, default=False) → None

Add an item to the select menu.

Parameters:
  • label (str) – Label of the item

  • value (str) – The value of the item, which will be shown on interaction response

  • description (str | None) – Description of the item

  • emoji (str | None) – Emoji shown on the left side of the item

  • default (bool) – Whether the item is selected by default

Raises:

ValueError – If there are more than 25 options

Return type:

None

custom_id: str

The custom ID of the select menu.

description: str | None

The description of the select menu (only works for modals).

disabled: bool

Whether the select menu is disabled or not.

label: str | None

The label of the select menu (only works for modals).

max_values: int | None

The maximum number of values that can be selected.

min_values: int | None

The minimum number of values that can be selected.

options
placeholder: str | None

The placeholder text for the select menu.

required: bool | None

Whether the select menu is required or not (only works for modals).

to_dict() → dict

Returns a dict representation of the select menu.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.Modal(*, title, custom_id=None)

Bases: InteractionStorage

Represents a modal component in a message.

Parameters:
  • title (str)

  • custom_id (str | None)

async callback(ctx) → BaseResponse | None

Called when the view is interacted with.

Return type:

BaseResponse | None

Parameters:

ctx (Context)

is_timeout() → bool

Whether the view has timed out.

Return type:

bool

property loop: AbstractEventLoop

The event loop this storage is running in.

async on_timeout() → None

Called when the view times out.

Return type:

None

async wait(ctx, *, call_after=None, users=None, original_response=False, custom_id=None, timeout=60) → Context | None

Tell the command to wait for an interaction response.

It will continue your code either if it was interacted with or timed out

Parameters:
  • ctx (Context) – Passing the current context of the bot

  • call_after (Callable | None) –

    Coroutine to call after the view is interacted with (will be ignored if timeout) The new context does follow with the call_after function, example:

    test = await view.wait(ctx, call_after=call_after, timeout=10)
    if not test:
        return None  # Timed out
    
    async def call_after(ctx):
        await ctx.response.edit_message(content="Hello world")
    

  • users (Iterable[Snowflake | int | str] | None) – Users that are allowed to interact with the view, as objects or IDs (int or a string of digits). Anyone else gets an ephemeral rejection.

  • original_response (bool) – Whether to force the original response to be used as the message target

  • custom_id (str | int | None) – Custom ID of the view, if not provided, it will use Context.id or Context.message

  • timeout (float | None) – How long it should take until the code simply times out. Set to None for the view to never time out on its own.

Return type:

Context | None

Returns:

Returns the new context of the interaction, or None if timed out

Raises:

TypeError –

  • If call_after is provided and is not a coroutine function - If users contains something that is not a user or an ID

title: str

The title of the modal.

custom_id: str

The custom ID of the modal.

items: list[TextDisplayComponent | LabelComponent | FileUploadComponent]

The items contained within the modal.

accepts(ctx) → bool

Whether an interaction is the submission of this modal.

Parameters:

ctx (Context) – The context of the interaction that arrived

Return type:

bool

add_item(component, *, label=None, description=None) → LabelComponent | TextDisplayComponent

Add an item to the modal.

Parameters:
Return type:

LabelComponent | TextDisplayComponent

Returns:

The created label component

Raises:

TypeError – If the component is not a TextInputComponent or Select

to_dict() → dict

Returns a dict representation of the modal.

Return type:

dict

class discord_http.view.Premium(sku_id)

Bases: Button

Button alias for the premium SKU style.

Parameters:

sku_id (Snowflake | int)

custom_id: str | None

The custom ID of the button.

disabled: bool

Whether the button is disabled or not.

emoji: str | dict | None

The emoji associated with the button.

label: str | None

The label of the button.

sku_id: Snowflake | int | None

The SKU ID of the button, only required for premium buttons.

style: ButtonStyles | str | int

The style of the button.

to_dict() → dict

Returns a dict representation of the button.

Return type:

dict

type: ComponentType

The type of the component.

url: str | None

The URL of the button, only required for link buttons.

class discord_http.view.RadioComponent(*options, custom_id, label=None, description=None, required=True)

Bases: Item

Represents a radio button component in a modal.

Parameters:
options: list[ComponentOption]

The options for the radio component.

custom_id: str

The custom ID of the radio component.

required: bool

Whether the radio component is required or not.

label: str | None

The label of the radio component.

description: str | None

The description of the radio component.

add_item(value, label, description=None, default=False) → None

Add an item to the radio component.

Parameters:
  • value (str) – The value of the option, which will be returned on interaction response

  • label (str) – The label of the option, what the user sees

  • description (str | None) – The description of the option, additional text shown below the label

  • default (bool) – Whether the option is the default selection

Return type:

None

to_dict() → dict

Returns a dict representation of the radio component.

Return type:

dict

type: ComponentType

The type of the component.

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:
  • placeholder (str | None)

  • custom_id (str | None)

  • min_values (int | None)

  • max_values (int | None)

  • default_values (list[Role | int] | None)

  • disabled (bool)

  • label (str | None)

  • description (str | None)

  • required (bool)

add_item(*, label, value, description=None, emoji=None, default=False) → None

Add an item to the select menu.

Parameters:
  • label (str) – Label of the item

  • value (str) – The value of the item, which will be shown on interaction response

  • description (str | None) – Description of the item

  • emoji (str | None) – Emoji shown on the left side of the item

  • default (bool) – Whether the item is selected by default

Raises:

ValueError – If there are more than 25 options

Return type:

None

custom_id: str

The custom ID of the select menu.

description: str | None

The description of the select menu (only works for modals).

disabled: bool

Whether the select menu is disabled or not.

label: str | None

The label of the select menu (only works for modals).

max_values: int | None

The maximum number of values that can be selected.

min_values: int | None

The minimum number of values that can be selected.

options
placeholder: str | None

The placeholder text for the select menu.

required: bool | None

Whether the select menu is required or not (only works for modals).

to_dict() → dict

Returns a dict representation of the select menu.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.SectionComponent(*components, accessory)

Bases: Item

Represents a section component in a message.

Parameters:
components: list[TextDisplayComponent | str]

The components contained within the section.

accessory: Button | ThumbnailComponent | AttachmentComponent | Asset | File | str

The accessory component for the section.

to_dict() → dict

Returns a dict representation of the section component.

Return type:

dict

type: ComponentType

The type of the component.

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:
  • label (str | None)

  • description (str | None)

  • placeholder (str | None)

  • custom_id (str | None)

  • min_values (int | None)

  • max_values (int | None)

  • disabled (bool)

  • options (list[dict] | None)

  • required (bool | None)

  • _type (ComponentType | None)

label: str | None

The label of the select menu (only works for modals).

description: str | None

The description of the select menu (only works for modals).

placeholder: str | None

The placeholder text for the select menu.

min_values: int | None

The minimum number of values that can be selected.

max_values: int | None

The maximum number of values that can be selected.

disabled: bool

Whether the select menu is disabled or not.

required: bool | None

Whether the select menu is required or not (only works for modals).

custom_id: str

The custom ID of the select menu.

add_item(*, label, value, description=None, emoji=None, default=False) → None

Add an item to the select menu.

Parameters:
  • label (str) – Label of the item

  • value (str) – The value of the item, which will be shown on interaction response

  • description (str | None) – Description of the item

  • emoji (str | None) – Emoji shown on the left side of the item

  • default (bool) – Whether the item is selected by default

Raises:

ValueError – If there are more than 25 options

Return type:

None

to_dict() → dict

Returns a dict representation of the select menu.

Return type:

dict

options
type: ComponentType

The type of the component.

class discord_http.view.SeparatorComponent(*, spacing=None, divider=None)

Bases: Item

Represents a separator component in a message.

Parameters:
spacing: SeparatorSpacingType | None

The spacing type of the separator.

divider: bool | None

Whether the separator is a divider or not.

to_dict() → dict

Returns a dict representation of the separator.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.TextDisplayComponent(content)

Bases: Item

Represents a text display component in a message.

Parameters:

content (str)

content: str

The content of the text display component.

to_dict() → dict

Returns a dict representation of the text display.

Return type:

dict

type: ComponentType

The type of the component.

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:
  • label (str | None)

  • description (str | None)

  • custom_id (str | None)

  • style (TextStyles | None)

  • placeholder (str | None)

  • min_length (int | None)

  • max_length (int | None)

  • default (str | None)

  • required (bool)

custom_id: str

The custom ID of the text input.

label: str | None

The label of the text input.

description: str | None

The description of the text input.

style: int

The style of the text input.

placeholder: str | None

The placeholder text of the text input.

min_length: int | None

The minimum length of the text input.

max_length: int | None

The maximum length of the text input.

default: str | None

The default value of the text input.

required: bool

Whether the text input is required or not.

to_dict() → dict

Returns a dict representation of the modal item.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.ThumbnailComponent(url, *, description=None, spoiler=False)

Bases: Item

Represents a thumbnail component in a message.

Parameters:
url: Asset | AttachmentComponent | str

The URL of the thumbnail image.

description: str | None

The description of the thumbnail.

spoiler: bool

Whether the thumbnail is a spoiler or not.

to_dict() → dict

Returns a dict representation of the thumbnail.

Return type:

dict

type: ComponentType

The type of the component.

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:
  • placeholder (str | None)

  • custom_id (str | None)

  • min_values (int | None)

  • max_values (int | None)

  • default_values (list[Member | int] | None)

  • disabled (bool)

  • label (str | None)

  • description (str | None)

  • required (bool)

add_item(*, label, value, description=None, emoji=None, default=False) → None

Add an item to the select menu.

Parameters:
  • label (str) – Label of the item

  • value (str) – The value of the item, which will be shown on interaction response

  • description (str | None) – Description of the item

  • emoji (str | None) – Emoji shown on the left side of the item

  • default (bool) – Whether the item is selected by default

Raises:

ValueError – If there are more than 25 options

Return type:

None

custom_id: str

The custom ID of the select menu.

description: str | None

The description of the select menu (only works for modals).

disabled: bool

Whether the select menu is disabled or not.

label: str | None

The label of the select menu (only works for modals).

max_values: int | None

The maximum number of values that can be selected.

min_values: int | None

The minimum number of values that can be selected.

options
placeholder: str | None

The placeholder text for the select menu.

required: bool | None

Whether the select menu is required or not (only works for modals).

to_dict() → dict

Returns a dict representation of the select menu.

Return type:

dict

type: ComponentType

The type of the component.

class discord_http.view.View(*items)

Bases: InteractionStorage

Represents a view component in a message.

Parameters:

items (Item)

async callback(ctx) → BaseResponse | None

Called when the view is interacted with.

Return type:

BaseResponse | None

Parameters:

ctx (Context)

is_timeout() → bool

Whether the view has timed out.

Return type:

bool

property loop: AbstractEventLoop

The event loop this storage is running in.

async on_timeout() → None

Called when the view times out.

Return type:

None

async wait(ctx, *, call_after=None, users=None, original_response=False, custom_id=None, timeout=60) → Context | None

Tell the command to wait for an interaction response.

It will continue your code either if it was interacted with or timed out

Parameters:
  • ctx (Context) – Passing the current context of the bot

  • call_after (Callable | None) –

    Coroutine to call after the view is interacted with (will be ignored if timeout) The new context does follow with the call_after function, example:

    test = await view.wait(ctx, call_after=call_after, timeout=10)
    if not test:
        return None  # Timed out
    
    async def call_after(ctx):
        await ctx.response.edit_message(content="Hello world")
    

  • users (Iterable[Snowflake | int | str] | None) – Users that are allowed to interact with the view, as objects or IDs (int or a string of digits). Anyone else gets an ephemeral rejection.

  • original_response (bool) – Whether to force the original response to be used as the message target

  • custom_id (str | int | None) – Custom ID of the view, if not provided, it will use Context.id or Context.message

  • timeout (float | None) – How long it should take until the code simply times out. Set to None for the view to never time out on its own.

Return type:

Context | None

Returns:

Returns the new context of the interaction, or None if timed out

Raises:

TypeError –

  • If call_after is provided and is not a coroutine function - If users contains something that is not a user or an ID

items: list[Item]

The items contained within the view, can be buttons, selects, links, etc.

accepts(ctx) → bool

Whether a component interaction came from one of this view’s own components.

Parameters:

ctx (Context) – The context of the interaction that arrived

Return type:

bool

get_item(*, label=None, custom_id=None) → Item | None

Get an item from the view that matches the parameters.

Parameters:
  • label (str | None) – Label of the item

  • custom_id (str | None) – Custom ID of the item

Return type:

Item | None

Returns:

Returns the item if found, otherwise None

add_item(item) → Item

Add an item to the view.

Parameters:

item (Item) – The item to add to the view

Return type:

Item

Returns:

Returns the added item

remove_items(*, label=None, custom_id=None) → int

Remove items from the view that match the parameters.

Parameters:
  • label (str | None) – Label of the item

  • custom_id (str | None) – Custom ID of the item

Return type:

int

Returns:

Returns the amount of items removed

to_dict() → list[dict]

Returns a dict representation of the view.

Return type:

list[dict]

classmethod from_dict(*, state, data) → View

Returns a view from a dict provided by Discord.

Return type:

View

Parameters: