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?

Instance Attribute Details

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

Returns The subcommands of the command.



144
145
146
# File 'lib/discorb/app_command/command.rb', line 144

def commands
  @commands
end

#description -> String (readonly)

Returns The description of the command.

Returns:

  • (String)

    The description of the command.



146
147
148
# File 'lib/discorb/app_command/command.rb', line 146

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:



183
184
185
186
187
188
# File 'lib/discorb/app_command/command.rb', line 183

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.

Returns:



163
164
165
166
167
168
# File 'lib/discorb/app_command/command.rb', line 163

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_s -> String

Returns the command name.

Returns:

  • (String)

    The command name.



195
196
197
# File 'lib/discorb/app_command/command.rb', line 195

def to_s
  @name
end