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

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

Overview

Represents the subcommand group.

Instance Attribute Summary collapse

Attributes inherited from GroupCommand

#description

Attributes inherited from Discorb::ApplicationCommand::Command

#block, #default_permission, #dm_permission, #guild_ids, #name, #type, #type_raw

Instance Method Summary collapse

Methods inherited from GroupCommand

#group

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#commandsArray<Discorb::ApplicationCommand::Command::ChatInputCommand> (readonly)

Returns The subcommands of the command.

Returns:



420
421
422
# File 'lib/discorb/app_command/command.rb', line 420

def commands
  @commands
end

Instance Method Details

#slash(command_name, description, options = {}, &block) ⇒ Discorb::ApplicationCommand::Command::ChatInputCommand

Add new subcommand.

Parameters:

  • command_name (String, Hash{Symbol => String})

    Command name. If hash is passed, it must be a pair of Language code and Command name, and :default key is required. You can use _ instead of - in language code.

  • description (String, Hash{Symbol => String})

    Command description. If hash is passed, it must be a pair of Language code and Command description, and :default key is required.

  • 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 | | --- | --- | --- | | :name_localizations | Hash=> String | Localizations of option name. | | :description | String | Hash{Symbol => String} | Description of the option. If hash is passed, it must be a pair of Language code and description, and :default key is required. You can use _ instead of - in language code. | | :required | Boolean(true | false) | Whether the argument is required. optional will be used if not specified. | | :optional | Boolean(true | false) | Whether the argument is optional. required will be used if not specified. | | :type | Object | Type of the option. | | :choices | Hash{String => String, Integer, Float} | Type of the option. | | :choices_localizations | Hash{String => Hash{Symbol => String}} | Localization of the choice. Key must be the name of a choice. | | :default | Object | Default value of the option. | | :channel_types | Array<Class<Discorb::Channel>> | Type of the channel option. | | :autocomplete | Proc | Autocomplete function. | | :range | Range | Range of the option. Only valid for numeric options. (:int, :float) | | :length | Range | Range of length of the option. Only valid for :string. |

  • guild_ids (Array<#to_s>, false, nil)

    Guild IDs to set the command to. false to global command, nil to use default.

  • dm_permission (Boolean)

    Whether the command is available in DM.

  • default_permission (Discorb::Permission)

    The default permission of the command.

  • block (Proc)

    Command block.

Returns:



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/discorb/app_command/command.rb', line 446

def slash(command_name, description, options = {}, &block)
  command =
    Discorb::ApplicationCommand::Command::ChatInputCommand.new(
      command_name,
      description,
      options,
      [],
      block,
      1,
      self,
      nil,
      nil
    )
  @commands << command
  @client.callable_commands << command
  command
end

#to_sObject



437
438
439
# File 'lib/discorb/app_command/command.rb', line 437

def to_s
  "#{@parent} #{@name}"
end