Class: RubyCord::Command::GroupCommand

Inherits:
RubyCord::Command show all
Defined in:
lib/rubycord/command/group_command.rb

Direct Known Subclasses

SubCommand

Constant Summary

Constants inherited from RubyCord::Command

VALID_LOCALES

Instance Attribute Summary collapse

Attributes inherited from RubyCord::Command

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

Instance Method Summary collapse

Methods inherited from RubyCord::Command

modify_localization_hash

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#commandsArray<RubyCord::Command> (readonly)

Returns The subcommands of the command.

Returns:



8
9
10
# File 'lib/rubycord/command/group_command.rb', line 8

def commands
  @commands
end

#descriptionHash{String => String} (readonly)

Returns The description of the command.

Returns:

  • (Hash{String => String})

    The description of the command.



10
11
12
# File 'lib/rubycord/command/group_command.rb', line 10

def description
  @description
end

Instance Method Details

#group(command_name, description) {|group| ... } ⇒ RubyCord::Command::SubCommand

Add new subcommand group.

Parameters:

  • command_name (String)

    Group name.

  • description (String)

    Group description.

Yields:

  • Block to yield with the command.

Yield Parameters:

Returns:



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rubycord/command/group_command.rb', line 84

def group(command_name, description)
  command =
    RubyCord::Command::SubCommand.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) ⇒ RubyCord::Command::SlashCommand

Add new subcommand.

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rubycord/command/group_command.rb', line 48

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

#to_sString

Returns the command name.

Returns:

  • (String)

    The command name.



102
103
104
# File 'lib/rubycord/command/group_command.rb', line 102

def to_s
  @name["default"]
end