Models

Note

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

Messages

Message

class slack.Message

This class is a constructor for the Message class. It takes in two parameters, state and data. The state parameter is a ConnectionState object, and the data parameter is a MessagePayload object. The function then sets the state, team_id, id, author, channel_id, and created_at attributes of the Message object

id

Message ID.

Type:

str

content

Message content.

Type:

str

property author: Member

Message author.

Returns:

Message author.

Return type:

Member

property channel: Channel

Message channel data.

Returns:

Message channel.

Return type:

Channel

property created_at: datetime

New in version 1.4.3.

Returns:

Returns the date and time of transmission.

Return type:

datetime

await delete() DeletedMessage

It deletes a message.

Returns:

A DeletedMessage object.

Changed in version 1.4.0: Return DeletedMessage

Return type:

DeletedMessage

await edit(text: str, is_bot: bool = True)

This function is a coroutine Edit sent message.

New in version 1.4.0.

Parameters:
  • text (str) – New message.

  • is_bot (bool) – If my(Bot) message, True.

Returns:

message data with edited timestamp.

Return type:

Message

property edited_at: datetime

New in version 1.4.3.

Returns:

Returns when it was edited. If not edited, returns the sender.

Return type:

datetime

property edited_by: Member

New in version 1.4.3.

Returns:

Returns who edited the file. If not edited, returns the sender.

Return type:

Member

await reaction_add(name: str, skin_tone_level: Optional[int] = None) None

Add a reaction to the specified message.

..versionadded:: 1.4.3

Parameters:
  • name (str) – Reaction name. See this URL for supported reactions.

  • skin_tone_level (int) –

await reactions() List[ReactionComponent]

Returns a list of reactions given to the specified message.

..versionadded:: 1.4.3

Return type:

List[ReactionComponent]

await replies() List[Message]

Get replied message from message id.

New in version 1.4.3.

Returns:

Returns original message and replied messages.

Return type:

List[Message]

await reply(text: str)

Create thread to this message.

New in version 1.4.3.

Parameters:

text (str) – Text you want reply.

Returns:

Sended message.

Return type:

Message

property team: Team

Message team.

Returns:

Message team.

Return type:

Team

DeletedMessage

class slack.DeletedMessage

This function is used to delete a message from a channel

ts

time when deleted.

Type:

datetime

property channel: Optional[Channel]

Deleted message’s channel.

Return type:

Optional[Channel]

property deleted_at: datetime

When deleted.

Return type:

datetime

property hidden

Is ephemeral.

Return type:

bool

JoinMessage

Methods
class slack.JoinMessage

This function is a constructor for the JoinMessage class. It takes in a ConnectionState and a JoinMessagePayload as parameters and sets the author of the message to the user in the JoinMessagePayload

property author: Member

Message author.

Returns:

Message author.

Return type:

Member

property channel: Channel

Message channel data.

Returns:

Message channel.

Return type:

Channel

property created_at: datetime

New in version 1.4.3.

Returns:

Returns the date and time of transmission.

Return type:

datetime

await delete() DeletedMessage

It deletes a message.

Returns:

A DeletedMessage object.

Changed in version 1.4.0: Return DeletedMessage

Return type:

DeletedMessage

await edit(text: str, is_bot: bool = True)

This function is a coroutine Edit sent message.

New in version 1.4.0.

Parameters:
  • text (str) – New message.

  • is_bot (bool) – If my(Bot) message, True.

Returns:

message data with edited timestamp.

Return type:

Message

property edited_at: datetime

New in version 1.4.3.

Returns:

Returns when it was edited. If not edited, returns the sender.

Return type:

datetime

property edited_by: Member

New in version 1.4.3.

Returns:

Returns who edited the file. If not edited, returns the sender.

Return type:

Member

await reaction_add(name: str, skin_tone_level: Optional[int] = None) None

Add a reaction to the specified message.

..versionadded:: 1.4.3

Parameters:
  • name (str) –

    Reaction name. See this URL for supported reactions.

  • skin_tone_level (int) –

await reactions() List[ReactionComponent]

Returns a list of reactions given to the specified message.

..versionadded:: 1.4.3

Return type:

List[ReactionComponent]

await replies() List[Message]

Get replied message from message id.

New in version 1.4.3.

Returns:

Returns original message and replied messages.

Return type:

List[Message]

await reply(text: str)

Create thread to this message.

New in version 1.4.3.

Parameters:

text (str) – Text you want reply.

Returns:

Sended message.

Return type:

Message

property team: Team

Message team.

Returns:

Message team.

Return type:

Team

ScheduledMessage

class slack.ScheduledMessage

A class of shedduled message.

..versionadded:: 1.4.3

id

Message id.

Type:

int

channel

Scheuled channel.

Type:

Channel

post_at

When post at.

Type:

int

date_created

When scheduled at.

Type:

int

content

Text content.

Type:

str

Blocks

Block

class slack.Block

This class be called on_block_actions() event. Different interactive components will cause an interaction payload to be sent at different moments.

member

Member who returned a response.

Type:

Member

trigger_id

Eigenvalue for response.

Type:

str

response_url

A short-lived webhook.

Type:

str

actions

Contains data from the specific interactive component that was used. App surfaces can contain blocks with multiple interactive components, and each of those components can have multiple values selected by users.

Type:

List[Action]

Examples

This class be called only on_block_actions() event.

@client.event
async def on_block_actions(block):
    action = block.actions[0]
    if action.get("action_id") == "action":
        await block.channel.send("Action called!!")

    else:
        await block.channel.send("This is not `action` event")
property channel: Optional[Channel]

returns: Return responsed channel :rtype: Optional[Channel]

property team: Optional[Team]

returns: Return responsed team. :rtype: Optional[Team]

Action

Attributes
class slack.Action

Contains data from the specific interactive component that was used. App surfaces can contain blocks with multiple interactive components, and each of those components can have multiple values selected by users.

block_id

Identifies the block within a surface that contained the interactive component that was used.

Type:

str

action_id

Identifies the interactive component itself. Some blocks can contain multiple interactive components, so the block_id alone may not be specific enough to identify the source component.

Type:

str

Channels

Channel

class slack.Channel

This function is a constructor for the Channel class. It takes in a ConnectionState object and a ChannelPayload object. It sets the state, id, name, team, created_at, and created_by attributes of the Channel object. It then calls the overload function

id

Channel ID.

Type:

str

team

Your team object.

Type:

Team

name

Account name.

Type:

str

created_at

When create this channel.

Type:

datetime

created_by

Who channel create.

Type:

Member

await archive() None

This function is a coroutine This channel archive as user.

await edit(name: Optional[str] = None, title: Optional[str] = None, purpose: Optional[str] = None, topic: Optional[str] = None) Channel

It edits the channel’s title, purpose, or topic.

New in version 1.4.3.

Parameters:
  • name (Optional[str]) – The new name of the channel.

  • title (Optional[str]) – The new title of the channel.

  • purpose (Optional[str]) – The purpose of the channel.

  • topic (Optional[str]) – The channel topic.

Returns:

Edited channel object.

Return type:

Channel

property everyone: str

New in version 1.4.0.

Return type:

str

await get_scheduled_messages(limit: Optional[int] = None, latest: Optional[datetime, int, float] = None, oldest: Optional[datetime, int, float] = None) List[Optional[ScheduledMessage]]

Examples

Examples

messages = await channel.get_scheduled_messages():
for message in messages:
    print(message.content)
Parameters:
  • limit (Optional[int]) –

  • latest (Optional[int, float, datetime]) –

  • oldest (Optional[int, float, datetime]) –

Return type:

List[Optional[ScheduledMessage]]

property here: str

New in version 1.4.0.

Return type:

str

await history() List[Message]

Examples

Examples

async for message in channel.history():
    print(message.content)
await kick(member: Member) None

Removes a user from a conversation.

..versionadded:: 1.4.3

Parameters:

member (Member) –

await leave(member: Member)

Leaves a conversation.

..versionadded:: 1.4.3

Parameters:

member (Member) – Member who leave channel.

await members(channel_id: Optional[str] = None) List[Optional[Member]]

Return List channel the calling user may access.

..versionadded:: 1.4.3

Parameters:

channel_id (Optional[str]) –

Returns:

Users participating in the channel.

Return type:

List[Optional[Member]]

await reaction_messages(*, team: Optional[Team] = None, member: Optional[Member] = None) List[Optional[Message]]

Returns a list of messages that have been reacted to on the specified channel.

..versionadded:: 1.4.3

Parameters:
  • team (Optional[Team]) – Team to be sent from.

  • member (Optional[Member]) – Member to be sent from.

await send(text: Optional[str] = None, view: Optional[ViewFrame] = None, as_user: bool = False) Message

This function is a coroutine

It sends a message to a channel.

Changed in version 1.4.0: Add view parameter.

Parameters:
  • text (Optional[str]) – The text of the message to send.

  • view (Optional[ViewFrame]) – The viewframe contain blocks of the message to send.

  • as_user (str) –

    Is message send by user or not.

    New in version 1.4.2.

Raises:

InvalidArgumentException – Raise when text and view are in param.

Returns:

A Message object.

Return type:

Message

await send_ephemeral(text: str, member: Member) datetime

This function is a coroutine Send Ephemeral message.

New in version 1.4.0.

Parameters:
  • text (str) – The text of the message to send.

  • member (Member) – send member.

Returns:

Message posted time.

Return type:

datetime

await send_file(attachment: Attachment) slack.File

This function occur sending file.

Parameters:

attachment (Attachment) – Your file to send.

Returns:

Sended data of file.

Return type:

File

await send_schedule(text: str, date: Union[datetime, int, float]) Message

This function is sending scheduled message with UNIX timestamp.

New in version 1.4.2.

Parameters:
  • text (str) – Message content.

  • date (Optional[datetime,:class:intfloat]) – Timestamp when scheduled message sending.

Returns:

Message object.

Return type:

Message

await unarchive() None

This channel unarchive.

..versionadded:: 1.4.3

DeletedChannel

Attributes
class slack.DeletedChannel

This function is called when a channel is deleted

channel_id

deleted channel id.

Type:

str

Teams

Attributes
Methods
class slack.Team

This function takes in a TeamPayload object and sets the data attribute of the Team object to the TeamPayload object

id

Team ID.

Type:

str

url

team link.

Type:

bool

icon

Team icon data.

Type:

Icon

name

Team name.

Type:

str

await create_channel(name: str, join: bool = True) Channel

Create new channel.

Parameters:
  • name (str) – new channel name.

  • join (bool) – is bot join.

Returns:

Return created channel.

Return type:

Channel

Icon

class slack.Icon

This function is used to initialize the Icon class

team

The team that the icon is for.

Type:

Team

image_default
Type:

bool

image_34

image url.

Type:

str

image_44
Type:

str

image_68
Type:

str

image_88
Type:

str

image_102
Type:

str

image_230
Type:

str

image_132
Type:

str

Members

Methods
class slack.Member

This function takes in a UserPayload object and assigns it to the data attribute of the User class

id

Your user ID.

Type:

str

team

Your team object.

Type:

Team

deleted

Account was deleted.

Type:

bool

color

Account icon color.

Type:

str

name

Account name.

Type:

str

bot

Is bot.

Type:

bool

property mention: str

Return member mention.

Returns:

mention.

Return type:

str

await send_dm(text: str)

New in version 1.4.2.

Parameters:

text (str) – Message you want as DM.

Return type:

Message

Reactions

ReactionComponent

Attributes
class slack.ReactionComponent

Information of reaction.

name

Reaction name.

Type:

:class:str`

members

A list of reacted members. Always contain the authenticated user, but might not always contain all users that have reacted.

Type:

List[Member]

count

Represent the count of all users who made that reaction.

Type:

int

Reaction-Event

class slack.ReactionEvent
type

Reaction type.

Type:

str

reaction

Reaction name.

Type:

str

file

Attachment ID(optional).

Type:

Optional[str]

file_comment

Attachment comment(optional).

Type:

Optional[str]

channel

Channel data(optional).

Type:

Channel

timestamp

Reaction added at.

Type:

datetime.datetime

message_timestamp

Message of reaction added timestamp.

Type:

datetime.datetime