Models

Note

Nearly all classes here have slots defined which means that it is impossible to have dynamic attributes to the data classes.

BaseView

View UI blocks

BaseView

class slack.view.BaseView

Base class of view object.

This class carries abstract methods for all components.

New in version 1.4.0.

Placeholder

Attributes
Methods
class slack.view.Placeholder

This represents placeholder for Select or Input

New in version 1.4.0.

text

Text for placeholder.

Type:

str

mrkdwn

Use markdown or not.

Type:

bool

emoji

Use emoji or not.

Type:

bool

to_dict()

Converts this object into a dict. :returns: A dictionary of str field keys bound to the respective value. :rtype: Dict[str, Union[str, bool]]

Select

class slack.view.Select

Represents a UI select menu with a list of custom options.

New in version 1.4.0.

action_id

ID for this event occured.

Type:

str

placeholder

Placeholder of select.

Type:

Optional[Placeholder]

options

Options to selections. Some type must be this attribute to select.

Type:

List[SelectOption]

select_type

Select type of this object.

Type:

SelectType

initial_text

Initial text for selections.

Type:

Optional[str]

to_dict()

Converts this object into a dict.

Returns:

A dictionary of str field keys bound to the respective value.

Return type:

Dict[str, Any]

SelectOption

Methods
class slack.view.SelectOption

Option for select items.

New in version 1.4.0.

text

Text of select.

Type:

str

value

Value of select.

Type:

str

description

Text description of select.

Type:

Optional[str]

mrkdwn

Markdown or nor.

Type:

Optional[bool]

to_dict()

Converts this object into a dict.

New in version 1.4.0.

Returns:

A dictionary of str field keys bound to the respective value.

Return type:

Dict[str, Dict[str, Union[str, bool]]]

Enums

SelectType

class slack.view.SelectType

Enums of select variety.

New in version 1.4.0.

ViewFrame

This is a frame of UI block.

ViewFrame

class slack.view.ViewFrame

This class is base class for all components.

This class carries abstract methods for all components.

New in version 1.4.0.

View

Attributes
Methods
class slack.view.View

This is a frame of view block. All blocks contains this instance.

New in version 1.4.0.

len(x)

Returns the total length of the blocks.

bool(b)

Returns whether this has one or more blocks.

Example:

select = Select(
    action_id="action",
    placeholder=Placeholder(
        "text", mrkdwn=False, emoji=True),
        select_type=SelectType.users_select,
        initial_text="initial"
)

view = View(select)
await message.channel.send(view=view)
blocks

Blocks of View.

Type:

List[BaseView]

add_block(block: Union[ActionView, SectionView]) View

Add block to the view object.

Parameters:

block (Union[ActionView, SectionView]) – Add block to this view object. Block must be inherit BaseView.

Returns:

Returns self object.

Return type:

View

to_list()

Converts this object into a dict.

Returns:

A dictionary of str embed field keys bound to the respective value.

Return type:

Dict[str, Any]

ActionView

slack.view.ActionView
class slack.view.ActionView

This class create action type instance.

New in version 1.4.2.

blocks

Component of blocks. MUst inherit BaseView.

Type:

BaseView

to_dict()

It takes a list of blocks, and returns a dictionary with the key “elements” and the value of a list of dictionaries, where each dictionary is the result of calling the to_dict() method on each block

Return type:

A dictionary with the key “type” and the value “actions”

SectionView

slack.view.SectionView
class slack.view.SectionView

This class create section type instance.

New in version 1.4.2.

block

Component of block. MUst inherit BaseView.

Type:

BaseView

text

Text of block.

Type:

str

to_dict()

to_dict is a function that takes in a self object and returns a list of dictionaries

Return type:

A list of dictionaries.