Class: Discordrb::ApplicationCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/interaction.rb

Overview

An ApplicationCommand for slash commands.

Constant Summary collapse

TYPES =

Command types. chat_input is a command that appears in the text input field. user and message types appear as context menus for the respective resource.

{
  chat_input: 1,
  user: 2,
  message: 3
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_idInteger (readonly)

Returns:



327
328
329
# File 'lib/discordrb/data/interaction.rb', line 327

def application_id
  @application_id
end

#default_permissiontrue, false (readonly)

Returns:

  • (true, false)


339
340
341
# File 'lib/discordrb/data/interaction.rb', line 339

def default_permission
  @default_permission
end

#descriptionString (readonly)

Returns:



336
337
338
# File 'lib/discordrb/data/interaction.rb', line 336

def description
  @description
end

#idInteger (readonly)

Returns:



345
346
347
# File 'lib/discordrb/data/interaction.rb', line 345

def id
  @id
end

#nameString (readonly)

Returns:



333
334
335
# File 'lib/discordrb/data/interaction.rb', line 333

def name
  @name
end

#optionsHash (readonly)

Returns:

  • (Hash)


342
343
344
# File 'lib/discordrb/data/interaction.rb', line 342

def options
  @options
end

#server_idInteger? (readonly)

Returns:



330
331
332
# File 'lib/discordrb/data/interaction.rb', line 330

def server_id
  @server_id
end

Instance Method Details

#deleteObject

Delete this application command.



388
389
390
# File 'lib/discordrb/data/interaction.rb', line 388

def delete
  @bot.delete_application_command(@id, server_id: @server_id)
end

#edit(name: nil, description: nil, default_permission: nil) {|, | ... } ⇒ Object

Parameters:

  • name (String) (defaults to: nil)

    The name to use for this command.

  • description (String) (defaults to: nil)

    The description of this command.

  • default_permission (true, false) (defaults to: nil)

    Whether this command is available with default permissions.

Yield Parameters:

  • (OptionBuilder)
  • (PermissionBuilder)


382
383
384
# File 'lib/discordrb/data/interaction.rb', line 382

def edit(name: nil, description: nil, default_permission: nil, &block)
  @bot.edit_application_command(@id, server_id: @server_id, name: name, description: description, default_permission: default_permission, &block)
end

#mention(subcommand_group: nil, subcommand: nil) ⇒ String Also known as: to_s

Returns the layout to mention it in a message.

Parameters:

  • subcommand (String, nil) (defaults to: nil)

    The subcommand to mention.

  • subcommand_group (String, nil) (defaults to: nil)

    The subcommand group to mention.

Returns:

  • (String)

    the layout to mention it in a message



363
364
365
366
367
368
369
370
371
372
373
# File 'lib/discordrb/data/interaction.rb', line 363

def mention(subcommand_group: nil, subcommand: nil)
  if subcommand_group && subcommand
    "</#{name} #{subcommand_group} #{subcommand}:#{id}>"
  elsif subcommand_group
    "</#{name} #{subcommand_group}:#{id}>"
  elsif subcommand
    "</#{name} #{subcommand}:#{id}>"
  else
    "</#{name}:#{id}>"
  end
end