Class: Discorb::ApplicationCommand::Command::GroupCommand

Inherits:
Discorb::ApplicationCommand::Command show all
Defined in:
lib/discorb/app_command/command.rb

Overview

Represents the command with subcommands.

Direct Known Subclasses

SubcommandGroup

Instance Attribute Summary collapse

Attributes inherited from Discorb::ApplicationCommand::Command

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

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#commandsArray<Discorb::ApplicationCommand::Command::SlashCommand, Discorb::ApplicationCommand::Command::SubcommandGroup> (readonly)

Returns The subcommands of the command.



180
181
182
# File 'lib/discorb/app_command/command.rb', line 180

def commands
  @commands
end

#descriptionString (readonly)

Returns The description of the command.

Returns:

  • (String)

    The description of the command.



182
183
184
# File 'lib/discorb/app_command/command.rb', line 182

def description
  @description
end

Instance Method Details

#group(command_name, description) {|group| ... } ⇒ Discorb::ApplicationCommand::Command::SubcommandGroup

Add new subcommand group.

Parameters:

  • command_name (String)

    Group name.

  • description (String)

    Group description.

Yields:

  • Block to yield with the command.

Yield Parameters:

Returns:

See Also:



228
229
230
231
232
233
# File 'lib/discorb/app_command/command.rb', line 228

def group(command_name, description, &block)
  command = Discorb::ApplicationCommand::Command::SubcommandGroup.new(command_name, description, @name, @client)
  command.yield_self(&block) if block_given?
  @commands << command
  command
end

#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:



208
209
210
211
212
213
# File 'lib/discorb/app_command/command.rb', line 208

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

#to_sString

Returns the command name.

Returns:

  • (String)

    The command name.



240
241
242
# File 'lib/discorb/app_command/command.rb', line 240

def to_s
  @name
end