Class: Discorb::Command::Command::SubcommandGroup

Inherits:
GroupCommand show all
Defined in:
lib/discorb/command.rb

Overview

Represents the subcommand group.

Instance Attribute Summary collapse

Attributes inherited from GroupCommand

#description

Attributes inherited from Discorb::Command::Command

#block, #guild_ids, #id_map, #name, #type, #type_raw

Instance Method Summary collapse

Methods inherited from GroupCommand

#group

Methods inherited from DiscordModel

#==, #eql?, #hash

Instance Attribute Details

#commandsArray<Discorb::Command::Command::SlashCommand> (readonly)

Returns The subcommands of the command.

Returns:



361
362
363
# File 'lib/discorb/command.rb', line 361

def commands
  @commands
end

Instance Method Details

#slash(command_name, description, options = {}, enabled: true, &block) ⇒ Discorb::Command::Command::SlashCommand

Add new subcommand.

Parameters:

  • command_name (String)

    Command name.

  • description (String)

    Command description.

  • options (Hash{String => Hash{:description => String, :optional => Boolean, :type => Object}}) (defaults to: {})

    Command options. The key is the option name, the value is a hash with the following keys:

    Key Type Description
    :description String Description of the option.
    :optional Boolean Whether the option is optional or not.
    :type Object Type of the option.
    :choice Hash{String => String, Integer, Float} Type of the option.
  • guild_ids (Array<#to_s>)

    Guild IDs to restrict the command to.

  • block (Proc)

    Command block.

Returns:



380
381
382
383
384
# File 'lib/discorb/command.rb', line 380

def slash(command_name, description, options = {}, enabled: true, &block)
  command = Discorb::Command::Command::SlashCommand.new(command_name, description, options, [], enabled, block, 1, @parent + " " + @name)
  @commands << command
  command
end

#to_sObject



371
372
373
# File 'lib/discorb/command.rb', line 371

def to_s
  @parent + " " + @name
end