Class: Discordrb::Events::ApplicationCommandEventHandler

Inherits:
EventHandler
  • Object
show all
Defined in:
lib/discordrb/events/interactions.rb

Overview

Event handler for ApplicationCommandEvents.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #match, #matches_all

Instance Attribute Details

#subcommandsHash (readonly)

Returns:

  • (Hash)


272
273
274
# File 'lib/discordrb/events/interactions.rb', line 272

def subcommands
  @subcommands
end

Instance Method Details

#group(name) {|| ... } ⇒ ApplicationCommandEventHandler

Parameters:

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)


284
285
286
287
288
289
290
291
292
# File 'lib/discordrb/events/interactions.rb', line 284

def group(name)
  raise ArgumentError, 'Unable to mix subcommands and groups' if @subcommands.any? { |_, v| v.is_a? Proc }

  builder = SubcommandBuilder.new(name)
  yield builder

  @subcommands.merge!(builder.to_h)
  self
end

#subcommand(name) {|| ... } ⇒ ApplicationCommandEventHandler

Parameters:

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)


297
298
299
300
301
302
303
# File 'lib/discordrb/events/interactions.rb', line 297

def subcommand(name, &block)
  raise ArgumentError, 'Unable to mix subcommands and groups' if @subcommands.any? { |_, v| v.is_a? Hash }

  @subcommands[name.to_sym] = block

  self
end