How do I stop the knocking?

I have a Honda Shadow Ace motorcycle and when you rev it there's a knocking noise coming from the engine. It runs well but it doesn't sound the best and if anyone has heard of this and knows what to do to stop this it would be great to know and a lot of help!

Engine is likely shot. See a bike mechanic.

Classic "knocking" (which actually sounds like tinkling), is due to bad / low octane gas, or hot spots (carbon deposits) in the head and / or valves. Heard of de-carbonizing? Yuppers dude, you can do that on a four-stroke. Parts crashing into each other can mean the valves are way out of adjustment or you've got worn crankshaft or con rods, or their bearings. But no maintenance history, no mileage, no year given. So try a tuneup.

Have one of your friends help you pinpoint where in the knocking is coming from, some parts 'knock' differently than others.
You will need a wooden dowel or stick about 12-16 inches to start with, and a good ear.
Place one end of the dowel to that ear and the other end on different parts of the engine while you rev or listen.

My first guess is the cam chain as they knock when they stretch and the tensioner is slack. Easy DIY if you have a few common tools or have a Bike Shop help you out.

If it's at the top it's probably the camshaft.
If deep inside the engine it's probably the Big End. Either will be expensive to fix and the engine will seize solid if not repaired.

The engine needs to be torn down to see what's broken.

There's no way of guessing what the problem is from your vague description, although that will not stop people predicting the death of the engine.

It could be something as simple as an auto-tension adjuster on a cam chain waiting to tick over.

There's some engine damage. Could be a rod or bearing gone bad.

Stop running the engine. This is serious. Mechanic shop repair now while it still works. It is moments from a cardiac arrest. It only needs 1 and it dies.