Engine knocking noise worsens with acceleration on 1998 Volkswagen Beetle TDI

I have a '98 VW Beetle TDI manual that is making a loud knocking noise. The noise seems to get louder with acceleration. When I shift gears and the engine winds down the noise continues. I did an oil change on the car and found metal shavings in the oil pan. Someone told me that I would need to replace the motor. Is it possible to repair the problem and not have to get a new motor? Any suggestions would be GREATLY appreciated.

If you found metal shavings in the oil, then you need to consider repairing, if possible the engine, sorry to say. The knocking is made from parts hitting each other because they are worn out and have too much clearance between the bearings.
Thank you I was hoping that I would be able to repair rather than replace the motor. I would like to try to do the work myself. Would you have any suggestions on how I should proceed?
Again thank you!