Class: RubyCord::Command
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- RubyCord::Command
- Defined in:
- lib/rubycord/command.rb,
lib/rubycord/command/sub_command.rb,
lib/rubycord/command/group_command.rb,
lib/rubycord/command/slash_command.rb
Overview
Represents the slash command.
Direct Known Subclasses
Defined Under Namespace
Classes: GroupCommand, SlashCommand, SubCommand
Constant Summary collapse
- VALID_LOCALES =
Returns List of valid locales.
%w[ da de en-GB en-US es-ES fr hr it lt hu nl no pl pt-BR ro fi sv-SE vi tr cs el bg ru uk hi th zh-CN ja zh-TW ko ].freeze
Instance Attribute Summary collapse
-
#block ⇒ Proc
readonly
The block of the command.
-
#default_permission ⇒ RubyCord::Permission
readonly
The default permissions for this command.
-
#dm_permission ⇒ Boolean
readonly
Whether the command is enabled in DMs.
-
#guild_ids ⇒ Array<RubyCord::Snowflake>
readonly
The guild ids that the command is enabled in.
-
#name ⇒ Hash{String => String}
readonly
The name of the command.
-
#type ⇒ :chat_input, ...
readonly
The type of the command.
-
#type_raw ⇒ Integer
readonly
The raw type of the command.
Class Method Summary collapse
Methods inherited from DiscordModel
Instance Attribute Details
#block ⇒ Proc (readonly)
Returns The block of the command.
49 50 51 |
# File 'lib/rubycord/command.rb', line 49 def block @block end |
#default_permission ⇒ RubyCord::Permission (readonly)
Returns The default permissions for this command.
55 56 57 |
# File 'lib/rubycord/command.rb', line 55 def @default_permission end |
#dm_permission ⇒ Boolean (readonly)
Returns Whether the command is enabled in DMs.
57 58 59 |
# File 'lib/rubycord/command.rb', line 57 def @dm_permission end |
#guild_ids ⇒ Array<RubyCord::Snowflake> (readonly)
Returns The guild ids that the command is enabled in.
47 48 49 |
# File 'lib/rubycord/command.rb', line 47 def guild_ids @guild_ids end |
#name ⇒ Hash{String => String} (readonly)
Returns The name of the command.
45 46 47 |
# File 'lib/rubycord/command.rb', line 45 def name @name end |
#type ⇒ :chat_input, ... (readonly)
Returns The type of the command.
51 52 53 |
# File 'lib/rubycord/command.rb', line 51 def type @type end |
#type_raw ⇒ Integer (readonly)
Returns The raw type of the command.
53 54 55 |
# File 'lib/rubycord/command.rb', line 53 def type_raw @type_raw end |
Class Method Details
.modify_localization_hash(hash) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/rubycord/command.rb', line 125 def self.modify_localization_hash(hash) hash.to_h do |rkey, value| key = rkey.to_s.gsub("_", "-") if VALID_LOCALES.none? { |valid| valid.downcase == key.downcase } && key != "default" raise ArgumentError, "Invalid locale: #{key}" end [ ( if key == "default" "default" else VALID_LOCALES.find { |valid| valid.downcase == key.downcase } end ), value ] end end |