Class: Discordrb::Events::ApplicationCommandEvent
- Inherits:
-
InteractionCreateEvent
- Object
- Event
- InteractionCreateEvent
- Discordrb::Events::ApplicationCommandEvent
- Defined in:
- lib/discordrb/events/interactions.rb
Overview
Event for ApplicationCommand interactions.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#command_id ⇒ Integer
readonly
The ID of the command.
-
#command_name ⇒ Symbol
readonly
The name of the command.
-
#options ⇒ Hash<Symbol, Object>
readonly
Arguments provided to the command, mapped as
Name => Value. -
#resolved ⇒ Resolved
readonly
The resolved channels, roles, users, members, and attachments for this event.
-
#subcommand ⇒ Symbol?
readonly
The name of the subcommand relevant to this event.
-
#subcommand_group ⇒ Symbol?
readonly
The name of the subcommand group relevant to this event.
-
#target_id ⇒ Integer?
readonly
The target of this command when it is a context command.
Attributes inherited from InteractionCreateEvent
#channel, #channel_id, #context, #interaction, #server, #server_id, #server_integration?, #type, #user, #user_integration?, #user_locale
Attributes inherited from Event
Instance Method Summary collapse
- #options_attachment(name) ⇒ Attachment
- #options_channel(name) ⇒ Channel
- #options_member(name) ⇒ Member
- #options_mentionable(name) ⇒ Member, Role
- #options_role(name) ⇒ Role
- #options_user(name) ⇒ User
-
#target ⇒ Message, ...
The target of this command, for context commands.
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_id ⇒ Integer (readonly)
Returns The ID of the command.
178 179 180 |
# File 'lib/discordrb/events/interactions.rb', line 178 def command_id @command_id end |
#command_name ⇒ Symbol (readonly)
Returns The name of the command.
175 176 177 |
# File 'lib/discordrb/events/interactions.rb', line 175 def command_name @command_name end |
#options ⇒ Hash<Symbol, Object> (readonly)
Returns Arguments provided to the command, mapped as Name => Value.
190 191 192 |
# File 'lib/discordrb/events/interactions.rb', line 190 def @options end |
#resolved ⇒ Resolved (readonly)
Returns The resolved channels, roles, users, members, and attachments for this event.
187 188 189 |
# File 'lib/discordrb/events/interactions.rb', line 187 def resolved @resolved end |
#subcommand ⇒ Symbol? (readonly)
Returns The name of the subcommand relevant to this event.
184 185 186 |
# File 'lib/discordrb/events/interactions.rb', line 184 def subcommand @subcommand end |
#subcommand_group ⇒ Symbol? (readonly)
Returns The name of the subcommand group relevant to this event.
181 182 183 |
# File 'lib/discordrb/events/interactions.rb', line 181 def subcommand_group @subcommand_group end |
#target_id ⇒ Integer? (readonly)
Returns The target of this command when it is a context command.
193 194 195 |
# File 'lib/discordrb/events/interactions.rb', line 193 def target_id @target_id end |
Instance Method Details
#options_attachment(name) ⇒ Attachment
269 270 271 |
# File 'lib/discordrb/events/interactions.rb', line 269 def (name) @resolved[:attachments][@options[name].to_i] end |
#options_channel(name) ⇒ Channel
257 258 259 |
# File 'lib/discordrb/events/interactions.rb', line 257 def (name) @resolved[:channels][@options[name].to_i] end |
#options_member(name) ⇒ Member
245 246 247 |
# File 'lib/discordrb/events/interactions.rb', line 245 def (name) @resolved[:members][@options[name].to_i] end |
#options_mentionable(name) ⇒ Member, Role
263 264 265 |
# File 'lib/discordrb/events/interactions.rb', line 263 def (name) member(name) || role(name) end |
#options_role(name) ⇒ Role
251 252 253 |
# File 'lib/discordrb/events/interactions.rb', line 251 def (name) @resolved[:roles][@options[name].to_i] end |
#options_user(name) ⇒ User
239 240 241 |
# File 'lib/discordrb/events/interactions.rb', line 239 def (name) @resolved[:users][@options[name].to_i] end |
#target ⇒ Message, ...
Returns The target of this command, for context commands.
231 232 233 234 235 |
# File 'lib/discordrb/events/interactions.rb', line 231 def target return nil unless @target_id @resolved.find { |data| data.key?(@target_id) }[@target_id] end |