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¶
- asyncdelete
- asyncedit
- asyncreaction_add
- asyncreaction_remove
- asyncreactions
- asyncreplies
- asyncreply
- 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
- 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:
- await edit(text: str, is_bot: bool = True)¶
This function is a coroutine Edit sent message.
New in version 1.4.0.
- 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:
- await reaction_add(name: str, skin_tone_level: int | None = None) None¶
Add a reaction to the specified message.
..versionadded:: 1.4.3
- 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]
DeletedMessage¶
JoinMessage¶
- asyncarchive
- asyncdelete
- asyncedit
- asyncget_permalink
- asyncget_scheduled_messages
- asynchistory
- asyncreaction_add
- asyncreaction_remove
- asyncreactions
- asyncreplies
- asyncreply
- asyncsend
- asyncsend_ephemeral
- asyncsend_file
- asyncsend_schedule
- 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 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:
- await edit(text: str, is_bot: bool = True)¶
This function is a coroutine Edit sent message.
New in version 1.4.0.
- 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:
- await get_permalink(message: Message) str¶
Retrieve a permalink URL for a specific extant message.
New in version 1.4.5.
- await get_scheduled_messages(limit: int | None = None, latest: datetime | int | float | None = None, oldest: datetime | int | float | None = None) list[ScheduledMessage | None]¶
Examples
Examples
messages = await channel.get_scheduled_messages(): for message in messages: print(message.content)
- await history() list[Message]¶
Examples
Examples
async for message in channel.history(): print(message.content)
- await reaction_add(name: str, skin_tone_level: int | None = None) None¶
Add a reaction to the specified message.
..versionadded:: 1.4.3
- 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 send(text: str | None = None, view: ViewFrame | None = 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:
- Raises:
InvalidArgumentException – Raise when text and view are in param.
- Returns:
A Message object.
- Return type:
- await send_ephemeral(text: str, member: Member) datetime¶
This function is a coroutine Send Ephemeral message.
New in version 1.4.0.
- 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
ScheduledMessage¶
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.- 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")
Action¶
- 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:
Channels¶
Channel¶
- asyncarchive
- asyncedit
- asyncget_permalink
- asyncget_scheduled_messages
- asynchistory
- asynckick
- asyncleave
- asyncmembers
- asyncreaction_messages
- asyncsend
- asyncsend_ephemeral
- asyncsend_file
- asyncsend_schedule
- asyncunarchive
- 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
- created_at¶
When create this channel.
- Type:
datetime
- await edit(name: str | None = None, title: str | None = None, purpose: str | None = None, topic: str | None = None) Channel¶
It edits the channel’s title, purpose, or topic.
New in version 1.4.3.
- await get_permalink(message: Message) str¶
Retrieve a permalink URL for a specific extant message.
New in version 1.4.5.
- await get_scheduled_messages(limit: int | None = None, latest: datetime | int | float | None = None, oldest: datetime | int | float | None = None) list[ScheduledMessage | None]¶
Examples
Examples
messages = await channel.get_scheduled_messages(): for message in messages: print(message.content)
- await history() list[Message]¶
Examples
Examples
async for message in channel.history(): print(message.content)
- await kick(member: Member) None¶
A way to
Member.kick() 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: str | None = None) list[Member | None]¶
Return List channel the calling user may access.
..versionadded:: 1.4.3
- await reaction_messages(*, team: Team | None = None, member: Member | None = None) list[Message | None]¶
Returns a list of messages that have been reacted to on the specified channel.
..versionadded:: 1.4.3
- await send(text: str | None = None, view: ViewFrame | None = 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:
- Raises:
InvalidArgumentException – Raise when text and view are in param.
- Returns:
A Message object.
- Return type:
- await send_ephemeral(text: str, member: Member) datetime¶
This function is a coroutine Send Ephemeral message.
New in version 1.4.0.
- 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
DeletedChannel¶
Teams¶
- class slack.Team¶
This function takes in a TeamPayload object and sets the data attribute of the Team object to the TeamPayload object