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

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

Overview

Represents the subcommand group.

Instance Attribute Summary collapse

Attributes inherited from GroupCommand

#description

Attributes inherited from Discorb::ApplicationCommand::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

#commands -> Array<Discorb::ApplicationCommand::Command::SlashCommand> (readonly)

Returns The subcommands of the command.

Returns:



372
373
374
# File 'lib/discorb/app_command.rb', line 372

def commands
  @commands
end

Instance Method Details

#slash(command_name, description, options = {}, &block) -> Discorb::ApplicationCommand::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. | | :required | Whether the argument is required. optional will be used if not specified. | | :optional | Whether the argument is optional. required will be used if not specified. | | :type | Object | Type of the option. | | :choice | Hash{String => String, Integer, Float} | Type of the option. | | :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) |

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

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

  • block (Proc)

    Command block.

Returns:



391
392
393
394
395
396
# File 'lib/discorb/app_command.rb', line 391

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

#to_s -> Object



382
383
384
# File 'lib/discorb/app_command.rb', line 382

def to_s
  @parent + " " + @name
end