Module: Slack::Web::Api::Endpoints::Reactions

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/reactions.rb

Instance Method Summary collapse

Instance Method Details

#reactions_add(options = {}) ⇒ Object

This method adds a reaction (emoji) to a message. Now that file threads work the way you'd expect, the file and file_comment arguments are deprecated. Specify channel and timestamp instead.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Reaction (emoji) name.

  • :channel (channel)

    Channel where the message to add reaction to was posted.

  • :file (file)

    File to add reaction to. Now that file threads work the way you'd expect, this argument is deprecated. Specify the timestamp and channel of the message associated with a file instead.

  • :file_comment (Object)

    File comment to add reaction to. Now that file threads work the way you'd expect, this argument is deprecated. Specify the timestamp and channel of the message associated with a file instead.

  • :timestamp (Object)

    Timestamp of the message to add reaction to.

See Also:


24
25
26
27
28
# File 'lib/slack/web/api/endpoints/reactions.rb', line 24

def reactions_add(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('reactions.add', options)
end

#reactions_get(options = {}) ⇒ Object

This method returns a list of all reactions for a single item (file, file comment, channel message, group message, or direct message).

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel where the message to get reactions for was posted.

  • :file (file)

    File to get reactions for.

  • :file_comment (Object)

    File comment to get reactions for.

  • :full (Object)

    If true always return the complete reaction list.

  • :timestamp (Object)

    Timestamp of the message to get reactions for.

See Also:


45
46
47
48
# File 'lib/slack/web/api/endpoints/reactions.rb', line 45

def reactions_get(options = {})
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('reactions.get', options)
end

#reactions_list(options = {}) ⇒ Object

This method returns a list of all items (file, file comment, channel message, group message, or direct message) reacted to by a user.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :cursor (Object)

    Parameter for pagination. Set cursor equal to the next_cursor attribute returned by the previous request's response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first “page” of the collection. See pagination for more details.

  • :full (Object)

    If true always return the complete reaction list.

  • :limit (Object)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached.

  • :user (user)

    Show reactions made by this user. Defaults to the authed user.

See Also:


63
64
65
66
67
68
69
70
71
72
# File 'lib/slack/web/api/endpoints/reactions.rb', line 63

def reactions_list(options = {})
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  if block_given?
    Pagination::Cursor.new(self, :reactions_list, options).each do |page|
      yield page
    end
  else
    post('reactions.list', options)
  end
end

#reactions_remove(options = {}) ⇒ Object

This method removes a reaction (emoji) from an item (file, file comment, channel message, group message, or direct message). One of file, file_comment, or the combination of channel and timestamp must be specified.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Object)

    Reaction (emoji) name.

  • :channel (channel)

    Channel where the message to remove reaction from was posted.

  • :file (file)

    File to remove reaction from.

  • :file_comment (Object)

    File comment to remove reaction from.

  • :timestamp (Object)

    Timestamp of the message to remove reaction from.

See Also:


90
91
92
93
94
# File 'lib/slack/web/api/endpoints/reactions.rb', line 90

def reactions_remove(options = {})
  throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  post('reactions.remove', options)
end