Class: Rancour::ApplicationCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/rancour/application_command.rb

Constant Summary collapse

SUB_COMMAND =
1
SUB_COMMAND_GROUP =
2
STRING =
3
INTEGER =
4
BOOLEAN =
5
USER =
6
CHANNEL =
7
ROLE =
8
MENTIONABLE =
9
NUMBER =
10
ATTACHMENT =
11

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, guild_id:, name:, value:, options:) ⇒ ApplicationCommand

Returns a new instance of ApplicationCommand.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rancour/application_command.rb', line 29

def initialize(id:, guild_id:, name:, value:, options:)
  self.id = id
  self.guild_id = guild_id
  self.name = name
  self.value = value
  self.options = []

  return if options.nil?

  self.options = options.map { |option| Interaction::Data.from_payload(option) }
end

Instance Attribute Details

#guild_idObject

Returns the value of attribute guild_id.



17
18
19
# File 'lib/rancour/application_command.rb', line 17

def guild_id
  @guild_id
end

#idObject

Returns the value of attribute id.



17
18
19
# File 'lib/rancour/application_command.rb', line 17

def id
  @id
end

#nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/rancour/application_command.rb', line 17

def name
  @name
end

#optionsObject

Returns the value of attribute options.



17
18
19
# File 'lib/rancour/application_command.rb', line 17

def options
  @options
end

#valueObject

Returns the value of attribute value.



17
18
19
# File 'lib/rancour/application_command.rb', line 17

def value
  @value
end

Class Method Details

.from_payload(payload) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/rancour/application_command.rb', line 19

def self.from_payload(payload)
  new(
    id: payload['id'],
    guild_id: payload['guild_id'],
    name: payload['name'],
    value: payload['value'],
    options: payload['options']
  )
end