module Discordrb::Commands
  # This module holds a collection of commands that can be easily added to by calling the {CommandContainer#command}
  # function. Other containers can be included into it as well. This allows for modularization of command bots.
  module CommandContainer
    def command(name, attributes = {}, &block)
      @commands ||= {}
      if name.is_a? Array
        new_command = Command.new(name[0], attributes, &block)
        name.each { |n| @commands[n] = new_command }
        new_command
      else
        @commands[name] = Command.new(name, attributes, &block)
      end
    end

    def remove_command(name)
      @commands ||= {}
      @commands.delete name
    end
  end
end

module Discordrb::Commands
  # This module holds a collection of commands that can be easily added to by calling the {CommandContainer#command}
  # function. Other containers can be included into it as well. This allows for modularization of command bots.
  module CommandContainer
    def command(name, attributes = {}, &block)
      @commands ||= {}
      if name.is_a? Array
        new_command = Command.new(name[0], attributes, &block)
        name.each { |n| @commands[n] = new_command }
        new_command
      else
        @commands[name] = Command.new(name, attributes, &block)
      end
    end

    def remove_command(name)
      @commands ||= {}
      @commands.delete name
    end

    # Adds all commands from another container into this one. Existing commands will be overwritten.
    # @param container [Module] A module that `extend`s {CommandContainer} from which the commands will be added.
    def include!(container)
      handlers = container.instance_variable_get '@commands'
      @commands ||= {}
      @commands.merge! handlers
    end
  end
end

Add an include method to the CommandContainer, similar to the EventContainer one
Add an include method to the CommandContainer, similar to the EventContainer one
