Class: Rubycord::Events::ApplicationCommandEventHandler

Inherits:
EventHandler
  • Object
show all
Defined in:
lib/rubycord/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)


234
235
236
# File 'lib/rubycord/events/interactions.rb', line 234

def subcommands
  @subcommands
end

Instance Method Details

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

Parameters:

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)


246
247
248
249
250
251
252
253
254
# File 'lib/rubycord/events/interactions.rb', line 246

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)


259
260
261
262
263
264
265
# File 'lib/rubycord/events/interactions.rb', line 259

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