Discarding as a cost to cast a spell will not trigger the ability. Only discarding as an effect will trigger the ability.

Artwork
Loading artwork…
Guerrilla Tactics
The List · #10E-211 · EN
Nonfoil—Foil—
Card rules
Guerrilla Tactics deals 2 damage to any target.
When a spell or ability an opponent controls causes you to discard this card, it deals 4 damage to any target.
Uncommon · Illustrated by Dave Dorman
Format legality
Commander Legal
Duel Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Pauper Legal
Pauper Commander Legal
Penny Legal
PreDH Legal
Premodern Legal
Tlr Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Old School Not Legal
Pioneer Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
If it is discarded, the damage done by it is done by this card due to an ability and not by a spell.
The second ability will trigger even on an optional discard caused by an opponent.