Class: Discorb::Command::Command::GroupCommand
- Inherits:
-
Discorb::Command::Command
- Object
- DiscordModel
- Discorb::Command::Command
- Discorb::Command::Command::GroupCommand
- Defined in:
- lib/discorb/command.rb
Overview
Represents the command with subcommands.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commands -> Array<Discorb::Command::Command::SlashCommand, Discorb::Command::Command::SubcommandGroup>
readonly
The subcommands of the command.
-
#description -> String
readonly
The description of the command.
Attributes inherited from Discorb::Command::Command
#block, #guild_ids, #id_map, #name, #type, #type_raw
Instance Method Summary collapse
-
#group(command_name, description) -> Discorb::Command::Command::SubcommandGroup
Add new subcommand group.
-
#slash(command_name, description, options = {}, &block) -> Discorb::Command::Command::SlashCommand
Add new subcommand.
-
#to_s -> String
Returns the command name.
Methods inherited from DiscordModel
Instance Attribute Details
#commands -> Array<Discorb::Command::Command::SlashCommand, Discorb::Command::Command::SubcommandGroup> (readonly)
Returns The subcommands of the command.
239 240 241 |
# File 'lib/discorb/command.rb', line 239 def commands @commands end |
#description -> String (readonly)
Returns The description of the command.
241 242 243 |
# File 'lib/discorb/command.rb', line 241 def description @description end |
Instance Method Details
#group(command_name, description) -> Discorb::Command::Command::SubcommandGroup
Add new subcommand group.
309 310 311 312 313 |
# File 'lib/discorb/command.rb', line 309 def group(command_name, description) command = Discorb::Command::Command::SubcommandGroup.new(command_name, description, @name) @commands << command command end |
#slash(command_name, description, options = {}, &block) -> Discorb::Command::Command::SlashCommand
Add new subcommand.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/discorb/command.rb', line 257 def slash(command_name, description, = {}, &block) command = Discorb::Command::Command::SlashCommand.new(command_name, description, , [], block, 1, @name) = .map do |name, value| ret = { type: case (value[:type].is_a?(Array) ? value[:type].first : value[:type]) when String, :string 3 when Integer 4 when TrueClass, FalseClass, :boolean 5 when Discorb::User, Discorb::Member, :user, :member 6 when Discorb::Channel, :channel 7 when Discorb::Role, :role 8 when :mentionable 9 when Float 10 end, name: name, description: value[:description], required: !value[:optional], } if value[:type].is_a?(Array) ret[:choices] = value[:type] end ret end { name: @name, default_permission: true, description: @description, options: , } @commands << command command end |
#to_s -> String
Returns the command name.
320 321 322 |
# File 'lib/discorb/command.rb', line 320 def to_s @name end |