The sentence you wrote is mostly correct! Here's the sentence:
Electric rays hunt by shocking the approaching fish with electricity.
It means that electric rays catch fish by giving them a shock with their electricity. The grammar is good, but if you want it to sound a little smoother, you could say:
- Electric rays hunt by shocking fish that come close to them with electricity.
- Electric rays hunt by using electricity to shock fish that approach.
Both are correct, but your original sentence is clear and gramatically correct!