View

discord_http.view module

class discord_http.view.Button(*, label: str | None = None, style: ButtonStyles | str | int = ButtonStyles.primary, disabled: bool = False, row: int | None = None, custom_id: str | None = None, sku_id: Snowflake | int | None = None, emoji: str | dict | None = None, url: str | None = None)[source]

Bases: Item

to_dict() dict[source]

dict: Returns a dict representation of the button

class discord_http.view.ChannelSelect(*channels: ChannelType | BaseChannel, placeholder: str | None = None, custom_id: str | None = None, min_values: int | None = 1, max_values: int | None = 1, row: int | None = None, disabled: bool = False)[source]

Bases: Select

to_dict() dict[source]

dict: Returns a dict representation of the channel select menu

class discord_http.view.Item(*, type: int, row: int | None = None)[source]

Bases: object

to_dict() dict[source]

dict: Returns a dict representation of the item

Bases: Button

class discord_http.view.MentionableSelect(*, placeholder: str | None = None, custom_id: str | None = None, min_values: int | None = 1, max_values: int | None = 1, row: int | None = None, disabled: bool = False)[source]

Bases: Select

class discord_http.view.Modal(*, title: str, custom_id: str | None = None)[source]

Bases: InteractionStorage

add_item(*, label: str, custom_id: str | None = None, style: TextStyles | None = None, placeholder: str | None = None, min_length: int | None = None, max_length: int | None = None, default: str | None = None, required: bool = True) ModalItem[source]

Add an item to the modal

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

  • custom_id (Optional[str]) – Custom ID of the item

  • style (Optional[TextStyles]) – Style of the item

  • placeholder (Optional[str]) – Placeholder of the item

  • min_length (Optional[int]) – Minimum length of the item

  • max_length (Optional[int]) – Maximum length of the item

  • default (Optional[str]) – Default value of the item

  • required (bool) – Whether the item is required

Returns:

Returns the created modal item from the items list

Return type:

ModalItem

to_dict() dict[source]

dict: Returns a dict representation of the modal

class discord_http.view.ModalItem(*, label: str, custom_id: str | None = None, style: TextStyles | None = None, placeholder: str | None = None, min_length: int | None = None, max_length: int | None = None, default: str | None = None, required: bool = True)[source]

Bases: object

to_dict() dict[source]

dict: Returns a dict representation of the modal item

class discord_http.view.Premium(*, sku_id: Snowflake | int, row: int | None = None)[source]

Bases: Button

class discord_http.view.RoleSelect(*, placeholder: str | None = None, custom_id: str | None = None, min_values: int | None = 1, max_values: int | None = 1, row: int | None = None, disabled: bool = False)[source]

Bases: Select

class discord_http.view.Select(*, placeholder: str | None = None, custom_id: str | None = None, min_values: int | None = 1, max_values: int | None = 1, row: int | None = None, disabled: bool = False, options: list[dict] | None = None, _type: int | None = None)[source]

Bases: Item

add_item(*, label: str, value: str, description: str | None = None, emoji: str | None = None, default: bool = False) None[source]

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 (Optional[str]) – Description of the item

  • emoji (Optional[str]) – 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

to_dict() dict[source]

dict: Returns a dict representation of the select menu

class discord_http.view.UserSelect(*, placeholder: str | None = None, custom_id: str | None = None, min_values: int | None = 1, max_values: int | None = 1, row: int | None = None, disabled: bool = False)[source]

Bases: Select

class discord_http.view.View(*items: Button | Select | Link)[source]

Bases: InteractionStorage

add_item(item: Button | Select | Link) Button | Select | Link[source]

Add an item to the view

Parameters:

item (Union[Button, Select, Link]) – The item to add to the view

Returns:

Returns the added item

Return type:

Union[Button, Select, Link]

classmethod from_dict(data: dict) View[source]

View: Returns a view from a dict provided by Discord

get_item(*, label: str | None = None, custom_id: str | None = None) Button | Select | Link | None[source]

Get an item from the view that matches the parameters

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

  • custom_id (Optional[str]) – Custom ID of the item

Returns:

Returns the item if found, otherwise None

Return type:

Optional[Union[Button, Select, Link]]

remove_items(*, label: str | None = None, custom_id: str | None = None) int[source]

Remove items from the view that match the parameters

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

  • custom_id (Optional[str]) – Custom ID of the item

Returns:

Returns the amount of items removed

Return type:

int

to_dict() list[dict][source]

list[dict]: Returns a dict representation of the view