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

Methods
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

created_at

Message created at.

Type:

datetime

property author: Optional[Member]

Message author.

Returns:

Message author.

Return type:

Optional[Member]

property channel: Channel

Message channel data.

Returns:

Message channel.

Return type:

Channel

await delete() DeletedMessage

It deletes a message.

Changed in version 1.4.0: Return DeletedMessage

Returns:

A DeletedMessage object.

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

await reply(text: str)
Parameters:

text (str) –

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

Attributes
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: Optional[Member]

Message author.

Returns:

Message author.

Return type:

Optional[Member]

property channel: Channel

Message channel data.

Returns:

Message channel.

Return type:

Channel

await delete() DeletedMessage

It deletes a message.

Changed in version 1.4.0: Return DeletedMessage

Returns:

A DeletedMessage object.

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

await reply(text: str)
Parameters:

text (str) –

Return type:

Message

property team: Team

Message team.

Returns:

Message team.

Return type:

Team

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.

property everyone: str

New in version 1.4.0.

Return type:

str

property here: str

New in version 1.4.0.

Return type:

str

await send(text: str)
await send(view: ViewFrame)

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_as_user(text: str)

This function is a coroutine Message is sended by you. not application.

Deprecated since version 1.4.2: Use :send: func.

Parameters:

text (str) – Message you want to send by your.

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) 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

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

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