Module: Discorb::ApplicationCommand

Defined in:
lib/discorb/app_command/common.rb,
lib/discorb/app_command/command.rb,
lib/discorb/app_command/handler.rb

Overview

Handles application commands.

Defined Under Namespace

Modules: Handler Classes: Command

Constant Summary collapse

VALID_LOCALES =

Returns List of valid locales.

Returns:

  • (Array<String>)

    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

Class Method Summary collapse

Class Method Details

.modify_localization_hash(hash) -> Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/discorb/app_command/common.rb', line 14

def modify_localization_hash(hash)
  hash.to_h do |rkey, value|
    key = rkey.to_s.gsub("_", "-")
    raise ArgumentError, "Invalid locale: #{key}" if VALID_LOCALES.none? do |valid|
                                                       valid.downcase == key.downcase
                                                     end && key != "default"

    [key == "default" ? "default" : VALID_LOCALES.find { |valid| valid.downcase == key.downcase }, value]
  end
end