The idiom is "Every cloud has a silver lining.". A cloud is bad in the sense that it might mean rain or that it blocks the sun. A silver lining is good because silver is a precious, expensive metal and owning some is a good thing.
So the idiom "silver lining" means that even bad things can have good parts or results if you look for them.
The lightning flash is a metaphor the writer is using relating back to the cloud with the silver lining. Iin a storm, when lightning flashes, the sky and the clouds are illuminated and easier to see. So, "If you can only grasp it when the lightning flashes." means, at the instant that the good thing becomes clear to see, you must seize the moment, or catch the chance, grab the good thing and not let go.