Class: Discordrb::Events::ApplicationCommandEvent

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

Overview

Event for ApplicationCommand interactions.

Direct Known Subclasses

AutocompleteEvent

Defined Under Namespace

Classes: Resolved

Instance Attribute Summary collapse

Attributes inherited from InteractionCreateEvent

#channel, #channel_id, #context, #interaction, #server, #server_id, #server_integration?, #type, #user, #user_integration?, #user_locale

Attributes inherited from Event

#bot

Instance Method Summary collapse

Methods inherited from InteractionCreateEvent

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

Instance Attribute Details

#command_idInteger (readonly)

Returns The ID of the command.

Returns:

  • (Integer)

    The ID of the command.



146
147
148
# File 'lib/discordrb/events/interactions.rb', line 146

def command_id
  @command_id
end

#command_nameSymbol (readonly)

Returns The name of the command.

Returns:

  • (Symbol)

    The name of the command.



143
144
145
# File 'lib/discordrb/events/interactions.rb', line 143

def command_name
  @command_name
end

#optionsHash<Symbol, Object> (readonly)

Returns Arguments provided to the command, mapped as Name => Value.

Returns:

  • (Hash<Symbol, Object>)

    Arguments provided to the command, mapped as Name => Value.



158
159
160
# File 'lib/discordrb/events/interactions.rb', line 158

def options
  @options
end

#resolvedResolved (readonly)

Returns:



155
156
157
# File 'lib/discordrb/events/interactions.rb', line 155

def resolved
  @resolved
end

#subcommandSymbol? (readonly)

Returns The name of the subcommand relevant to this event.

Returns:

  • (Symbol, nil)

    The name of the subcommand relevant to this event.



152
153
154
# File 'lib/discordrb/events/interactions.rb', line 152

def subcommand
  @subcommand
end

#subcommand_groupSymbol? (readonly)

Returns The name of the subcommand group relevant to this event.

Returns:

  • (Symbol, nil)

    The name of the subcommand group relevant to this event.



149
150
151
# File 'lib/discordrb/events/interactions.rb', line 149

def subcommand_group
  @subcommand_group
end

#target_idInteger? (readonly)

Returns The target of this command when it is a context command.

Returns:

  • (Integer, nil)

    The target of this command when it is a context command.



161
162
163
# File 'lib/discordrb/events/interactions.rb', line 161

def target_id
  @target_id
end

Instance Method Details

#targetMessage, ...

Returns The target of this command, for context commands.

Returns:

  • (Message, User, nil)

    The target of this command, for context commands.



199
200
201
202
203
# File 'lib/discordrb/events/interactions.rb', line 199

def target
  return nil unless @target_id

  @resolved.find { |data| data.key?(@target_id) }[@target_id]
end