Class: OnyxCord::ApplicationCommand
- Inherits:
-
Object
- Object
- OnyxCord::ApplicationCommand
- Defined in:
- lib/onyxcord/interactions/internal/application_command.rb
Overview
An ApplicationCommand for slash commands.
Defined Under Namespace
Classes: Permission
Constant Summary collapse
- TYPES =
Command types.
chat_inputis a command that appears in the text input field.userandmessagetypes appear as context menus for the respective resource. { chat_input: 1, user: 2, message: 3, primary_entry_point: 4 }.freeze
Instance Attribute Summary collapse
- #application_id ⇒ Integer readonly
- #contexts ⇒ Array<Integer> readonly
- #default_permission ⇒ true, false readonly
- #description ⇒ String readonly
- #id ⇒ Integer readonly
- #integration_types ⇒ Array<Integer> readonly
- #name ⇒ String readonly
- #nsfw ⇒ true, false readonly
- #options ⇒ Hash readonly
- #server_id ⇒ Integer? readonly
Instance Method Summary collapse
-
#delete ⇒ Object
Delete this application command.
- #edit(name: nil, description: nil, default_permission: nil, nsfw: nil, &block) ⇒ Object
-
#mention(subcommand_group: nil, subcommand: nil) ⇒ String
(also: #to_s)
The layout to mention it in a message.
-
#permissions(server_id: nil) ⇒ Array<Permission>
Get the permission configuration for this application command in a specific server.
Instance Attribute Details
#application_id ⇒ Integer (readonly)
16 17 18 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 16 def application_id @application_id end |
#contexts ⇒ Array<Integer> (readonly)
40 41 42 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 40 def contexts @contexts end |
#default_permission ⇒ true, false (readonly)
28 29 30 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 28 def @default_permission end |
#description ⇒ String (readonly)
25 26 27 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 25 def description @description end |
#id ⇒ Integer (readonly)
34 35 36 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 34 def id @id end |
#integration_types ⇒ Array<Integer> (readonly)
43 44 45 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 43 def integration_types @integration_types end |
#name ⇒ String (readonly)
22 23 24 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 22 def name @name end |
#nsfw ⇒ true, false (readonly)
37 38 39 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 37 def nsfw @nsfw end |
#options ⇒ Hash (readonly)
31 32 33 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 31 def @options end |
#server_id ⇒ Integer? (readonly)
19 20 21 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 19 def server_id @server_id end |
Instance Method Details
#delete ⇒ Object
Delete this application command.
90 91 92 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 90 def delete @bot.delete_application_command(@id, server_id: @server_id) end |
#edit(name: nil, description: nil, default_permission: nil, nsfw: nil, &block) ⇒ Object
84 85 86 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 84 def edit(name: nil, description: nil, default_permission: nil, nsfw: nil, &block) @bot.edit_application_command(@id, server_id: @server_id, name: name, description: description, default_permission: , nsfw: nsfw, &block) end |
#mention(subcommand_group: nil, subcommand: nil) ⇒ String Also known as: to_s
Returns the layout to mention it in a message.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 64 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 |
#permissions(server_id: nil) ⇒ Array<Permission>
Get the permission configuration for this application command in a specific server.
97 98 99 100 101 102 103 104 105 |
# File 'lib/onyxcord/interactions/internal/application_command.rb', line 97 def (server_id: nil) raise ArgumentError, 'A server ID must be provided for global application commands' if @server_id.nil? && server_id.nil? response = OnyxCord::Internal::JSON.parse(REST::Application.(@bot.token, @bot.profile.id, @server_id || server_id&.resolve_id, @id)) response['permissions'].map { || Permission.new(, response, @bot) } rescue OnyxCord::Errors::UnknownError # If there aren't any explicit overwrites configured for the command, the response is a 400. [] end |