Method: Discordrb::Message#reacted_with
- Defined in:
- lib/discordrb/data/message.rb
#reacted_with(reaction, limit: 100) ⇒ Array<User>
Returns the list of users who reacted with a certain reaction.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/discordrb/data/message.rb', line 305 def reacted_with(reaction, limit: 100) reaction = reaction.to_reaction if reaction.respond_to?(:to_reaction) reaction = reaction.to_s if reaction.respond_to?(:to_s) get_reactions = proc do |fetch_limit, after_id = nil| resp = API::Channel.get_reactions(@bot.token, @channel.id, @id, reaction, nil, after_id, fetch_limit) return JSON.parse(resp).map { |d| User.new(d, @bot) } end # Can be done without pagination return get_reactions.call(limit) if limit && limit <= 100 paginator = Paginator.new(limit, :down) do |last_page| if last_page && last_page.count < 100 [] else get_reactions.call(100, last_page&.last&.id) end end paginator.to_a end |