3rd-level Transmutation

Casting Time: 1 bonus action (which you take immediately after hitting or missing a target with a ranged attack using a weapon)

Range: Self

Components: V, S

Duration: Instantaneous

As your attack hits or misses the target, the weapon or ammunition you’re using transforms into a lightning bolt. Instead of taking any damage or other effects from the attack, the target takes 4d8 Lightning damage on a hit or half as much damage on a miss. Each creature within 10 feet of the target then makes a Dexterity saving throw, taking 2d8 Lightning damage on a failed save or half as much damage on a successful one.

The weapon or ammunition then returns to its normal form.

Using a Higher-Level Spell Slot.

The damage for both effects of the spell increases by 4d8 for each spell slot level above 3.