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, #default_permission, #dm_permission, #guild_ids, #name, #type, #type_raw

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

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

Returns The subcommands of the command.

Returns:



217
218
219
# File 'lib/discorb/app_command/command.rb', line 217

def commands
  @commands
end

#description -> Hash{String => String} (readonly)

Returns The description of the command.

Returns:

  • (Hash{String => String})

    The description of the command.



219
220
221
# File 'lib/discorb/app_command/command.rb', line 219

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:



281
282
283
284
285
286
# File 'lib/discorb/app_command/command.rb', line 281

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

#slash(command_name, description, options = {}, dm_permission: true, default_permission: nil, &block) -> Discorb::ApplicationCommand::Command::ChatInputCommand

Add new subcommand.

Returns:



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/discorb/app_command/command.rb', line 251

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

#to_s -> String

Returns the command name.

Returns:

  • (String)

    The command name.



293
294
295
# File 'lib/discorb/app_command/command.rb', line 293

def to_s
  @name["default"]
end