Module: OnyxCord::CogMeta::ClassMethods

Defined in:
lib/onyxcord/cogs/cog_meta.rb

Instance Method Summary collapse

Instance Method Details

#application_commandsObject



45
46
47
# File 'lib/onyxcord/cogs/cog_meta.rb', line 45

def application_commands
  @application_commands ||= {}
end

#command(name, attributes = {}, &block) ⇒ Object



29
30
31
# File 'lib/onyxcord/cogs/cog_meta.rb', line 29

def command(name, attributes = {}, &block)
  super(name, command_attrs.merge(attributes), &block)
end

#command_attrs(attributes = nil) ⇒ Object



24
25
26
27
# File 'lib/onyxcord/cogs/cog_meta.rb', line 24

def command_attrs(attributes = nil)
  @command_attrs = attributes.dup if attributes
  @command_attrs ||= {}
end

#description(value = nil) ⇒ Object



19
20
21
22
# File 'lib/onyxcord/cogs/cog_meta.rb', line 19

def description(value = nil)
  @description = value unless value.nil?
  @description
end

#listener(*names, **attributes, &block) ⇒ Object

Raises:

  • (ArgumentError)


49
50
51
52
53
54
# File 'lib/onyxcord/cogs/cog_meta.rb', line 49

def listener(*names, **attributes, &block)
  raise ArgumentError, 'Listener requires at least one event name' if names.empty?
  raise ArgumentError, 'Listener requires a block' unless block

  listeners << { names: names.map(&:to_sym), attributes: attributes, block: block }
end

#listenersObject



56
57
58
# File 'lib/onyxcord/cogs/cog_meta.rb', line 56

def listeners
  @listeners ||= []
end

#message_command(name, **attributes, &block) ⇒ Object



41
42
43
# File 'lib/onyxcord/cogs/cog_meta.rb', line 41

def message_command(name, **attributes, &block)
  application_commands[name.to_s] = Interactions::Command.message(name, **attributes, &block)
end

#slash(name, description:, **attributes, &block) ⇒ Object



33
34
35
# File 'lib/onyxcord/cogs/cog_meta.rb', line 33

def slash(name, description:, **attributes, &block)
  application_commands[name.to_s] = Interactions::Command.chat_input(name, description: description, **attributes, &block)
end

#user_command(name, **attributes, &block) ⇒ Object



37
38
39
# File 'lib/onyxcord/cogs/cog_meta.rb', line 37

def user_command(name, **attributes, &block)
  application_commands[name.to_s] = Interactions::Command.user(name, **attributes, &block)
end