Class: Discordrb::Events::AutocompleteEventHandler

Inherits:
InteractionCreateEventHandler show all
Defined in:
lib/discordrb/events/interactions.rb

Overview

Event handler for an autocomplete option choices.

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #initialize, #match, #matches_all

Constructor Details

This class inherits a constructor from Discordrb::Events::EventHandler

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/discordrb/events/interactions.rb', line 487

def matches?(event)
  return false unless super
  return false unless event.is_a?(AutocompleteEvent)

  [
    matches_all(@attributes[:name], event.focused) { |a, e| a&.to_s == e },
    matches_all(@attributes[:command_id], event.command_id) { |a, e| a&.to_i == e },
    matches_all(@attributes[:subcommand], event.subcommand) { |a, e| a&.to_sym == e },
    matches_all(@attributes[:command_name], event.command_name) { |a, e| a&.to_sym == e },
    matches_all(@attributes[:subcommand_group], event.subcommand_group) { |a, e| a&.to_sym == e },
    matches_all(@attributes[:server], event.server_id) { |a, e| a&.resolve_id == e }
  ].reduce(&:&)
end