Class: Discordrb::Events::AutocompleteEvent

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

Overview

An event for an autocomplete option choice.

Instance Attribute Summary collapse

Attributes inherited from ApplicationCommandEvent

#command_id, #command_name, #options, #resolved, #subcommand, #subcommand_group, #target_id

Attributes inherited from InteractionCreateEvent

#channel, #channel_id, #interaction, #server, #server_id, #type, #user

Attributes inherited from Event

#bot

Instance Method Summary collapse

Methods inherited from ApplicationCommandEvent

#target

Methods inherited from InteractionCreateEvent

#defer, #defer_update, #delete_message, #delete_response, #edit_message, #edit_response, #get_component, #send_message, #show_modal, #update_message

Instance Attribute Details

#choicesHash (readonly)

Returns An empty hash that can be used to return choices by adding K/V pairs.

Returns:

  • (Hash)

    An empty hash that can be used to return choices by adding K/V pairs.



508
509
510
# File 'lib/discordrb/events/interactions.rb', line 508

def choices
  @choices
end

#focusedString (readonly)

Returns Name of the currently focused option.

Returns:

  • (String)

    Name of the currently focused option.



505
506
507
# File 'lib/discordrb/events/interactions.rb', line 505

def focused
  @focused
end

Instance Method Details

#respond(choices:) ⇒ Object

Respond to this interaction with autocomplete choices.

Parameters:

  • choices (Array<Hash>, Hash, nil)

    Autocomplete choices to return.



532
533
534
# File 'lib/discordrb/events/interactions.rb', line 532

def respond(choices:)
  @interaction.show_autocomplete_choices(choices || [])
end