Slack v0.23.5 Slack.Web.Channels View Source
Link to this section Summary
Functions
Archives a channel
Creates a channel
Fetches history of messages and events from a channel
Gets information about a channel
Invites a user to a channel
Joins a channel, creating it if needed
Removes a user from a channel
Leaves a channel
Lists all channels in a Slack team
Sets the read cursor in a channel
Renames a channel
Retrieve a thread of messages posted to a channel
Sets the purpose for a channel
Sets the topic for a channel
Unarchives a channel
Link to this section Functions
archive(channel, optional_params \\ %{}) View Source
Archives a channel.
Required Params
channel- Channel to archive
Errors the API can return:
already_archived- Channel has already been archived.cant_archive_general- You cannot archive the general channelchannel_not_found- Value passed forchannelwas invalid.last_ra_channel- You cannot archive the last channel for a restricted accountrestricted_action- A team preference prevents the authenticated user from archiving.
create(name, optional_params \\ %{}) View Source
Creates a channel.
Required Params
name- Name of channel to create ex:mychannel
Errors the API can return:
name_taken- A channel cannot be created with the given name.no_channel- Value passed fornamewas empty.restricted_action- A team preference prevents the authenticated user from creating channels.
history(channel, optional_params \\ %{}) View Source
Fetches history of messages and events from a channel.
Required Params
channel- Channel to fetch history for.
Optional Params
count- Number of messages to return, between 1 and 1000. ex:100inclusive- Include messages with latest or oldest timestamp in results. ex:1latest- End of time range of messages to include in results.oldest- Start of time range of messages to include in results.unreads- Includeunread_count_displayin the output? ex:1
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.invalid_ts_latest- Value passed forlatestwas invalidinvalid_ts_oldest- Value passed foroldestwas invalid
info(channel, optional_params \\ %{}) View Source
Gets information about a channel.
Required Params
channel- Channel to get info on
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.
invite(channel, user, optional_params \\ %{}) View Source
Invites a user to a channel.
Required Params
channel- Channel to invite user to.user- User to invite to channel.
Errors the API can return:
already_in_channel- Invited user is already in the channel.cant_invite- User cannot be invited to this channel.cant_invite_self- Authenticated user cannot invite themselves to a channel.channel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.not_in_channel- Authenticated user is not in the channel.user_not_found- Value passed foruserwas invalid.
join(name, optional_params \\ %{}) View Source
Joins a channel, creating it if needed.
Required Params
name- Name of channel to join
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.name_taken- A channel cannot be created with the given name.no_channel- Value passed fornamewas empty.restricted_action- A team preference prevents the authenticated user from creating channels.
kick(channel, user, optional_params \\ %{}) View Source
Removes a user from a channel.
Required Params
channel- Channel to remove user from.user- User to remove from channel.
Errors the API can return:
cant_kick_from_general- User cannot be removed from #general.cant_kick_from_last_channel- User cannot be removed from the last channel they're in.cant_kick_self- Authenticated user can't kick themselves from a channel.channel_not_found- Value passed forchannelwas invalid.not_in_channel- User was not in the channel.restricted_action- A team preference prevents the authenticated user from kicking.user_not_found- Value passed foruserwas invalid.
leave(channel, optional_params \\ %{}) View Source
Leaves a channel.
Required Params
channel- Channel to leave
Errors the API can return:
cant_leave_general- Authenticated user cannot leave the general channelchannel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.
list(optional_params \\ %{}) View Source
Lists all channels in a Slack team.
Optional Params
exclude_archived- Don't return archived channels. ex:1
mark(channel, ts, optional_params \\ %{}) View Source
Sets the read cursor in a channel.
Required Params
channel- Channel to set reading cursor in.ts- Timestamp of the most recently seen message.
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.invalid_timestamp- Value passed fortimestampwas invalid.not_in_channel- Caller is not a member of the channel.
rename(channel, name, optional_params \\ %{}) View Source
Renames a channel.
Required Params
channel- Channel to renamename- New name for channel.
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.invalid_name- New name is invalidname_taken- New channel name is takennot_authorized- Caller cannot rename this channelnot_in_channel- Caller is not a member of the channel.
replies(channel, thread_ts, optional_params \\ %{}) View Source
Retrieve a thread of messages posted to a channel.
Required Params
channel- Channel to fetch thread fromthread_ts- Unique identifier of a thread's parent message.
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.thread_not_found- Value for thread_ts was missing or invalid.
set_purpose(channel, purpose, optional_params \\ %{}) View Source
Sets the purpose for a channel.
Required Params
channel- Channel to set the purpose ofpurpose- The new purpose ex:My Purpose
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.not_in_channel- Authenticated user is not in the channel.too_long- Purpose was longer than 250 characters.user_is_restricted- Setting the purpose is a restricted action.
set_topic(channel, topic, optional_params \\ %{}) View Source
Sets the topic for a channel.
Required Params
channel- Channel to set the topic oftopic- The new topic ex:My Topic
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.not_in_channel- Authenticated user is not in the channel.too_long- Topic was longer than 250 characters.user_is_restricted- Setting the topic is a restricted action.
unarchive(channel, optional_params \\ %{}) View Source
Unarchives a channel.
Required Params
channel- Channel to unarchive
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.not_archived- Channel is not archived.