Module: ESM::Command::Base::Definition

Extended by:
ActiveSupport::Concern
Included in:
ESM::Command::Base
Defined in:
lib/esm/command/base/definition.rb

Overview

Methods involved with defining or creating a Command for ESM

Defined Under Namespace

Classes: Attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



323
324
325
# File 'lib/esm/command/base/definition.rb', line 323

def category
  @category
end

#cooldown_timeObject (readonly)

Returns the value of attribute cooldown_time.



323
324
325
# File 'lib/esm/command/base/definition.rb', line 323

def cooldown_time
  @cooldown_time
end

#current_channelObject

Returns the value of attribute current_channel.



325
326
327
# File 'lib/esm/command/base/definition.rb', line 325

def current_channel
  @current_channel
end

#current_communityObject

Returns the value of attribute current_community.



325
326
327
# File 'lib/esm/command/base/definition.rb', line 325

def current_community
  @current_community
end

#current_userObject

Returns the value of attribute current_user.



325
326
327
# File 'lib/esm/command/base/definition.rb', line 325

def current_user
  @current_user
end

#eventObject (readonly)

Returns the value of attribute event.



323
324
325
# File 'lib/esm/command/base/definition.rb', line 323

def event
  @event
end

#nameObject (readonly)

Returns the value of attribute name.



323
324
325
# File 'lib/esm/command/base/definition.rb', line 323

def name
  @name
end

#permissionsObject (readonly)

Returns the value of attribute permissions.



323
324
325
# File 'lib/esm/command/base/definition.rb', line 323

def permissions
  @permissions
end

#responseObject (readonly)

Returns the value of attribute response.



322
323
324
# File 'lib/esm/command/base/definition.rb', line 322

def response
  @response
end

#timersObject (readonly)

Returns the value of attribute timers.



323
324
325
# File 'lib/esm/command/base/definition.rb', line 323

def timers
  @timers
end

Instance Method Details

#initialize(user: nil, server: nil, channel: nil, arguments: {}) ⇒ Object



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/esm/command/base/definition.rb', line 329

def initialize(user: nil, server: nil, channel: nil, arguments: {})
  command_class = self.class

  # These can be modified on the fly. Disconnect them from the class
  self.skipped_actions = skipped_actions.dup
  self.requirements = requirements.dup

  @name = command_class.command_name
  @category = command_class.category
  @attributes = attributes.to_istruct

  @current_user = ESM::User.from_discord(user)
  @current_community = ESM::Community.from_discord(server)
  @current_channel = channel
  @arguments = ESM::Command::Arguments.new(
    self,
    templates: command_class.arguments,
    values: arguments
  )

  @timers = Timers.new(name)
end