Module: AdvancedRubyCommandHandler::CommandHandler

Defined in:
lib/advanced_ruby_command_handler/app/command_handler.rb

Class Method Summary collapse

Class Method Details

.load_commands(client) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/advanced_ruby_command_handler/app/command_handler.rb', line 7

def self.load_commands(client)
  commands = []
  Dir.entries(client.commands_dir).each do |dir|
    next if %w[. ..].include?(dir)

    Dir.entries("#{client.commands_dir}/#{dir}").each do |file|
      next if %w[. ..].include?(file)

      p "#{client.commands_dir}/#{dir}/#{file}"

      load "#{client.commands_dir}/#{dir}/#{file}"

      commands << File.basename(file, ".rb")
    end
  end
  commands
end