Whenever you cast an artifact spell, you may draw a card. If you do, discard a card.
An ability that triggers when a player casts a spell resolves before the spell that caused it to trigger. It resolves even if that spell is countered.
You draw a card and discard a card all while Riddlesmith's ability is resolving. Nothing can happen between the two, and no player may choose to take actions.